0

Hi,
I am trying to write a small shell script that will take user input on SVN branch and validate that
the requested branch exists in SVN. And then continue with other operations if the branch is valid.
I tried the following but seems its not working right:

VALID_BRANCHES="4.2.1 4.1.0 4.3.1 4.2.2"

for brnache in $VALID_BRANCHES
do 
    echo "Checking if $brnache is a valid branch in SVN"
    if [ "$1" != "$brnache" ];
    then
        echo "it isn't"
        continue
    else
        echo "$1 is a valid branch"
        break
    fi
done
2
Contributors
3
Replies
11
Views
4 Years
Discussion Span
Last Post by Watael
0

Oh,,sorry. Let me try again to explain my problem.
I want to check if the branch exists. So it compares the user input will all existing branches. Until it finds a match it keeps comparig. Soon it finds a match it continues, if no match it exits al together.

My script continues with or without a match.

0

you need at least a variable that's set or not depending on user's input branch exists or not, which would be tested to exit the script or not.

var=""
for  i in blue yellow red
do
    test "purple" = "$i" && { var=1; break;} || { var=0; continue;}
done
test $var -eq 0 && echo "no match: exit script" || echo "match: continue script"

continue and break are only useful for for, while, or until command, they will not exit, or continue the script.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.