On 8/31/26 5:42 AM, Mike Jonkmans wrote:
[In bash, one can use just '!' as the command: empty() { !; } anywhere a command is required, but that is, like our '{ }', non-standard.$ empty bash: !: event not found
That's history expansion; you can turn that off (`set +H') in an interactive shell or use
A space is needed between the '!' and the ';':
$ empty() { ! ; }
as you discovered. I'm pretty sure kre was using a script.
When using 'set -e', prevent exits with:
$ empty() { ! ! ; }
Things are a bit weird around !
$ ! ## $? = 1
$ ! ! ## $? = 0
$ ! ; ## $? = 1
$ ( set -e; ! ; echo foo ) ## foo (expected no output)
Which looks like a minor issue.
A `false pipeline' (see my message to kre) exits with status 1, but the null command is still having its exit status inverted, so it doesn't cause the shell to exit. That's more consistent -- every time you see a `!' it means the exit status is being inverted and `set -e' doesn't apply -- but not exactly in the letter of the interpretation.
It probably isn't documented though, I didn't check, so don't assume it won't get fixed sometime.]From the bash manual: The format for a pipeline is: [time [-p]] [ ! ] command1 [ [|⎪|&] command2 ... ] Assuming command1 can not be empty (which is not explicitly documented). In the bash-implementation a pipeline is more like: [time [-p]] [ ! ] [ command1 [ [|⎪|&] command2 ... ] ]
See the grammar changes from interp 267.
As also valid are: $ time
A "shelltime pipeline."
$ time !
It didn't seem harmful to support it. You can also use `! time'.
Being able to leave out the last ';' in { ... } would be really nice.
The close brace is a reserved word, not an operator.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature
