tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Empty sub-shells and command groups in /bin/sh
Oh, and while I am here, another possible change, especially if we are
doing things only in posix mode, is in the way the ! word is processed.
In posix, ! is allowed in exactly one place (and there can be only one ! there).
That one place is before a pipeline (note that all simple commands
are also pipelines, just ones containing only one process, and no pipes...)
That is
! false
is OK, as is
! mount | grep | ...
but
! ! false
is not, nor is
mount | ! grep | ...
! also cannot be used ahead of any compound command (no ! ( ... )
or ! while ... etc)
The posix syntax actually makes some sense, the ! ! syntax we simply treat
as a no-op (it does nothing at all - any even number of ! words, any odd
number is the same as 1) and in pipes (ones with more than one command) the
exit status is defined as the exit status of the last command, all the other
processes' exit statuses (statii?) are ignored. So, if we want the opposite
exit status, a single ! in front of the whole pipeline is sufficient.
Putting a ! in front of any of the other commands (would) just cause its
exit status to be inverted before being ignored... (but if you really want
to do it
mount | { ! grep ; } |
is legal (useless, but legal).
I was not planning on changing how the NetBSD shell handles ! but I could
in posix mode, making ! legal only where it should be, and not in the myriad
of other places the shell currently processes it.
Opions?
kre
ps: Also, if we do keep ! ! should it be changed to work as (for example) !!x
does in C, which is the same as "x ? 1 : 0" ? Currently the implementation
(ignoring even numbers of !'s) means we get "x ? x : 0" (ie: x).
Home |
Main Index |
Thread Index |
Old Index