Reputation: 9062
I'm copying a bash script from a Linux box to my Mac laptop and in the process, the script has started complaining about the usage of ;&
.
With the error:
./build.sh: line 122: syntax error near unexpected token `;'
./build.sh: line 122: ` ;&'
There's a few uses in the script, but a short one is:
case ${OPTION} in
xxx)
export DEVICES=xxx
;;
yyy)
export DEVICES=yyy
;;
*)
echo "${OPTION}: Unknown device type: use xxx|yyy"
exit 1
;&
esac
;;
I've replaced all usages of ;&
with ;;
and I think that everything is ok, but I'm still curious what I've done. What's the difference between semicolon-ampersand and double semicolon in case statements?
Upvotes: 5
Views: 2724
Reputation: 113864
From man bash
:
Using ;& in place of ;; causes execution to continue with the list associated with the next set of patterns.
Since ;&
occurs on the last pattern in the case
statement, it should make no difference in that script.
Upvotes: 8