On 4/11/19 4:18 PM, Toralf Förster wrote: > Given: > > $> cat <<EOF >shift.sh > #!/bin/bash > # > > shift 3 > > echo ">>${@}<<" > EOF > > then a call with less than 3 parameter, eg. "./shift.sh 1 2" gives ">>1 2<<". > Whilst the man page does not deny this behaviour I do wonder if a feature > request to get ">><<" instead is sufficient here?
I'm not inclined to add it; no other POSIX shell does it. And the standard has this to say: "If the n operand is invalid or is greater than "$#", this may be considered a syntax error and a non-interactive shell may exit; if the shell does not exit in this case, a non-zero exit status shall be returned." If you want to be sure to shift out all existing parameters, use `shift $#'. If you want something else, you can add logic to cap the argument passed to `shift' at $#. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/
signature.asc
Description: OpenPGP digital signature