You can skip positional parameters with shift but can you delete positional parameters by passing the position?
x(){ CODE; echo "$@"; }; x 1 2 3 4 5 6 7 8
> 1 2 4 5 6 7 8
I would like to add CODE to x() to delete positional parameter 3. I don’t want to do echo "${@:1:2} ${@:4:8}". After running CODE, $@ should only contain “1 2 4 5 6 7 8”.
The best way, if you want to be able to pass on the parameters to another process, or handle space separated parameters, is to re-
setthe parameters:To test that it works with non-trivial parameters:
(Yes,
$'\b'is a backspace)