Answer the question
In order to leave comments, you need to log in
How to handle getting a param=value parameter in bash?
Hello.
I need to make a script that accepts --enable-all and --birds=5 parameters, while the parameters can be passed in any order.
I process the first one like this:
for PARAM in [email protected]; do
case $PARAM in
--enable-all)
EnableAll=1 ;;
--enable-toster)
EnableToster=1 ;;
-h|--help)
SHOW_HELP ;;
esac
done
Answer the question
In order to leave comments, you need to log in
Try
for PARAM in [email protected]; do
case $PARAM in
-ea=* | --enable-all=*)
ENABLEALL = "${i#*=}"
shift
;;
"${i#*=}"
is roughly equivalent`sed 's/[^=]*=//' <<< "$i"`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question