Shell if-else嵌套循环错误
这是我的脚本…我在下面得到了这个错误。我怀疑second else是错的,但我无法找出答案Shell if-else嵌套循环错误,shell,loops,if-statement,scripting,nested,Shell,Loops,If Statement,Scripting,Nested,这是我的脚本…我在下面得到了这个错误。我怀疑second else是错的,但我无法找出答案 read -p "Do you wish to continue the merge session? (y/n) " RESP if [ "$RESP" = "y" ]; then co_repo=`echo $target_url | cut -d "/" -f 7` co_workspace="svn_promote_$co_repo" echo "$co_workspace
read -p "Do you wish to continue the merge session? (y/n) " RESP
if [ "$RESP" = "y" ]; then
co_repo=`echo $target_url | cut -d "/" -f 7`
co_workspace="svn_promote_$co_repo"
echo "$co_workspace ................................................."
if [-d "$co_workspace" ] then;
echo -e "Creating target workspace $co_workspace"
echo -e ""
mkdir $co_workspace
echo -e "Checking out $target_url .."
svn co $target_url $co_workspace
else
echo -e "Target workspace exists. Updating ..."
svn update $co_workspace
fi
else
echo "Exiting promote session .."
fi
错误:
monday_try.sh: line 44: syntax error near unexpected token `else'
monday_try.sh: line 44: ` else'
分号在
之前,然后是,而不是在它之后。分号在之前,然后是,而不是在它之后。什么是@Wumpus说的,加上
if [-d "$co_workspace" ]
在[
后面需要一个空格:
if [ -d "$co_workspace" ]
还有,@Wumpus说了什么
if [-d "$co_workspace" ]
在[
后面需要一个空格:
if [ -d "$co_workspace" ]
@iaav,记住[
是一个命令,帮助记住它需要被spaces@iaav,记住,[
是一个命令,有助于记住它需要被空格包围