How to remove a positional parameter from $@
POSIXly:
for arg do
shift
[ "$arg" = "-inf" ] && continue
set -- "$@" "$arg"
done
printf '%s\n' "$@"
The above code even works in pre-POSIX shells, except the original Almquist shell (Read Endnote). Change the for
loop to:
for arg
do
...
done
guarantee to work in all shells.
Another POSIX one:
for arg do
shift
case $arg in
(-inf) : ;;
(*) set -- "$@" "$arg" ;;
esac
done
With this one, you need to remove the first (
in (pattern)
to make it work in pre-POSIX shells.