Linux 为什么我在bashshell脚本中出现这个错误
我一直在尝试向我的bashshell脚本添加一个选项,即有人执行“-r”操作,我推送到git服务器,但我得到了以下错误Linux 为什么我在bashshell脚本中出现这个错误,linux,git,bash,Linux,Git,Bash,我一直在尝试向我的bashshell脚本添加一个选项,即有人执行“-r”操作,我推送到git服务器,但我得到了以下错误 mirror.sh: line 8: conditional binary operator expected mirror.sh: line 8: syntax error near `-e' mirror.sh: line 8: `if [[ "$1" -e "-r" ]];then' 下面是我的bash脚本: #!/bin/bash cd /home/joe/Docum
mirror.sh: line 8: conditional binary operator expected
mirror.sh: line 8: syntax error near `-e'
mirror.sh: line 8: `if [[ "$1" -e "-r" ]];then'
下面是我的bash脚本:
#!/bin/bash
cd /home/joe/Documents/sourcecode/mirror.git
git svn rebase
#
# if option -r then push to master
#
if [[ "$1" -e "-r" ]];then
git push origin master
fi
尝试:
if[“$1”=“-r”];然后
或
if[[“$1”==“-r”];那么
那么:
if [[ "$1" == "-r" ]]; then
?
-e在您的示例中测试文件是否存在。这是错误的。如前所述
-e
确实是一个错误。我猜您想比较值并考虑使用-eq
,但这是一个错误。您需要==
将字符串作为
if [[ "$1" == "-r" ]];
-据我所知,eq是整数之间的算术比较。