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

hi,

«is not working right» is not very descriptive.

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.