disCopperBld=
for x; do
if [ "$x" = "-disCopperBld" ]; then disCopperBld=1; break; fi
done
if [ -n "$disCopperBld" ]; then
...
fi
If you need to test only the parameters starting at $3
, do the search in a function:
## Usage: search_trailing_parameters NEEDLE NUM "$@"
## Search NEEDLE amongst the parameters, skipping $1 through ${$NUM}.
search_trailing_parameters () {
needle=$1
shift $(($2 + 2))
for x; do
if [ "$x" = "$needle" ]; then return 0; fi
done
return 1
}
if search_trailing_parameters -disCopperBld 2 "$@"; then
...
fi
But I wonder why you're trying to do this in the first place, it's not a common need. Usually, you'd process options in order, as in Dennis's answer to your previous questionas in Dennis's answer to your previous question.