I'm trying to write a script where I want to check if any of the parameters passed to a bash script match a string. The way I have it setup right now is
if [ "$3" != "-disCopperBld" -a "$4" != "-disCopperBld" -a "$5" != "-disCopperBld" -a "$6" != "-disCopperBld"]
but there might be a large number of parameters, so I was wondering if there is a better way to do this?
Thanks
EDIT: I tried this chunk of code out, and called the script with the option, -disableVenusBld, but it still prints out "Starting build". Am I doing something wrong? Thanks in advance!
while [ $# -ne 0 ]
do
arg="$1"
case "$arg" in
-disableVenusBld)
disableVenusBld=true
;;
-disableCopperBld)
disableCopperBld=true
;;
-disableTest)
disableTest=true
;;
-disableUpdate)
disableUpdate=true
;;
*)
nothing="true"
;;
esac
shift
done
if [ "$disableVenusBld" != true ]; then
echo "Starting build"
fi
#! /bin/sh -
to the top of what you've included there, made the script executable, then./t.sh
prints "Starting build", but./t.sh -disableVenusBld
prints nothing.for a in "$@"; do [[ "$a" == "-disCopperBld" ]] && echo match; done