0

This is my script ...i get this error below. I suspect second if else is wrong but unble to figure that out ..

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

Error:

monday_try.sh: line 44: syntax error near unexpected token `else'
monday_try.sh: line 44: `                    else'

2 Answers 2

3

Semicolon goes before then, not after it.

Sign up to request clarification or add additional context in comments.

Comments

1

What @Wumpus says, plus

if [-d "$co_workspace" ]

needs a space after the [:

if [ -d "$co_workspace" ]

1 Comment

@iaav, remember [ is a command, helps to remember it needs to be surrounded by spaces

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.