
bash 不會從登入終端取得文件,除非我從終端手動執行 bash,我有 bash(而不是 sh 或 dash)。當我獲取文件時,它會返回錯誤(例如“語法錯誤接近意外”),除非我不運行$ 重擊源之前
$echo $TERM
screen-256color
$echo $SHELL
/bin/bash
$shopt login_shell
login_shell on
錯誤:
$source ./shrc
-bash: ./shrc: line 105: syntax error near unexpected token `('
$bash
$source ./shrc <-- now it works
有任何想法嗎?
更新1
當我運行 bash 時,我進入 non_login shell,並且它可以工作。為什麼登入 shell 無法取得來源檔案?
更新2
$echo $0
-bash
$bash
$echo $0
bash
更新3
else
echo;
echo "The SPEC environment variable is not set! Please source the shrc and try again."
echo;
fi
}
ogo() { <----- LINE 105
SHRC_NO_GO=0
TOP=$SPEC
if [ "x$TOP" != "x" ]; then
if [ "x$1" = "x--help" -o "x$1" = "x-h" ]; then
這是來自 SPEC2006 基準測試的文件(是眾所周知的程序,不是我的程式碼)我的假設是它是正確的。 (事實上,在非登入 shell 上,它是有效的)
答案1
$SHELL
儲存您的預設 shell,而不是目前 shell。嘗試echo $0
改為:
$ echo $SHELL
/bin/bash
$ echo $0
dash