[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/50896: sloppy usage checking in shell builtin 'shift'
>Synopsis: sloppy usage checking in shell builtin 'shift'
>Arrival-Date: Sat Mar 05 13:20:00 +0000 2016
>Originator: Robert Elz
>Release: NetBSD 7.99.26 (all versions up to today (at least))
System: NetBSD andromeda.noi.kre.to 7.99.26 NetBSD 7.99.26 (VBOX64-1.1-20160128) #43: Thu Jan 28 16:09:08 ICT 2016 kre%onyx.coe.psu.ac.th@localhost:/usr/obj/current/kernels/amd64/VBOX64 amd64
The shell builtin "shift" takes an optional single numeric
argument. Our shell correctly tests whether that arg (if
given) is in fact numeric, and errors (as it should) if not.
It also checks it is in range, and errors (as it is allowed
to do - optional behavior is for shift to return a non-zero
status) if not. (It also sub-optimally handles the weird
case of "shift 0" but that's so rare it isn't worth putting
in special code to optimize it.)
What it doesn't do (and no do most other shells it seems,
though bash does) is object if there is more than 1 arg.
sh -c "set -- a b c; shift 1 foo; echo this output should not appear"
Since shift is a special builtin, in a non-interactive shell
the erroneous shift should cause the shell to exit (with an
I have a fix for this (it is trivial), it will be in one of
the next set of patches that get applied to sh. This PR is
really just a placeholder to the cvs commit log can refer to it.
It is also supremely unimportant, so there will be no great rush
to get the patch applied... it can wait until there are more to
happen at the same time.
Main Index |
Thread Index |