当我尝试'if: Expression syntax'
时,我的.profile
出现了source ~/.profile
错误。我究竟做错了什么? .profile file
答案 0 :(得分:0)
链接中的代码看起来“确定”,在我的bash
环境中运行了“确定”,并在“ ShellCheck”中签出为“确定”。
从OP的评论中,以下内容不会生成语法错误:
$ bash
$ source ./.profile
$ <<<=== no error message, just a command prompt
这确认在.profile
环境中OP的bash
的内容是否正确。
从其他评论中得知:
$ echo $SHELL
/bin/tcsh
问题出在这里... tcsh
与bash
不同,这也意味着在{{1}下执行时,OP .profile
中的某些命令无效}} shell。
如果我们转到Try It Online,向下滚动并选择tcsh
,请输入以下代码,即可确认这一点...
tcsh
...然后运行代码,我们得到:
tty -s
if test $? = 0
then
stty dec crt
fi
要解决此语法问题,有两种选择:
if: Expression Syntax.
(请参阅bash
或让sysadmin更新chsh
以将/etc/passwd
Shell替换为tcsh
贝壳);完成此操作后,所有新的登录/ shell会话都将在采购OP的bash
.profile
,然后手动获取bash