![嘗試取得 ~/.bash_profile 時出現 Bash 權限被拒絕錯誤](https://rvso.com/image/1438134/%E5%98%97%E8%A9%A6%E5%8F%96%E5%BE%97%20~%2F.bash_profile%20%E6%99%82%E5%87%BA%E7%8F%BE%20Bash%20%E6%AC%8A%E9%99%90%E8%A2%AB%E6%8B%92%E7%B5%95%E9%8C%AF%E8%AA%A4.png)
我不明白為什麼會出現這個錯誤
-bash: /dev/ttys000: Permission denied
當我嘗試獲取我的~/.bash_profile
?除了最近安裝的 Csound 之外,我的設定 (OS X 10.10.1) 沒有任何變更。
答案1
只是在黑暗中一槍:你的腳本或命令中~/.bash_profile
嘗試寫入的/dev/ttys000
內容已關閉,無法為該進程/用戶寫入。
如果您想確定錯誤是在哪裡產生的,請嘗試啟用目前 shell 的偵錯:
set -x # To enable debugging
source ~/.bash_profile # source the file
set +x # To disable debugging
如果您找到了誰/為什麼並且無法解決問題,請發布另一個相關問題。
範例:
文件中aaa.sh
有:
date +"%H:%M:%S"
ls /ahksfjkasd
echo Hi!
的輸出set -x; source aaa.sh; set +x
是:
++ date +%H:%M:%S
17:54:09
++ ls --color=auto /ahksfjkasd
ls: cannot access /ahksfjkasd: No such file or directory
++ echo 'Hi!'
Hi!
錯誤是從 ( ++ ls --color /ahksfjkasd
)之前的行產生的