How do I do this:
set foo bar baz
unset # Something else here
echo $# # Should ouput 0
By doing set "", $# will still be 1 and not 0.
Ok this was just stupid, and I found out using set -- will work.
set - with no arguments leaves the positional parameters unchanged.
set --. I have used set - (single hyphen), which says: "If there are no args, the positional parameters remain unchanged."
Easily unset all positional parameters with:
shift $#
To remove the first 3 positional parameters:
shift 3
Shift "pops" off the first N positional parameters. By using $# we get the total number of positional parameters. The command thus pops off all the positional parameters.