嘗試取得 ~/.bash_profile 時出現 Bash 權限被拒絕錯誤

嘗試取得 ~/.bash_profile 時出現 Bash 權限被拒絕錯誤

我不明白為什麼會出現這個錯誤

-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)之前的行產生的

相關內容