-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2326
Vidar Holen edited this page Jul 31, 2023
·
1 revision
cat | ! tee /dev/full
Either negate the entire pipeline (this is equivalent unless pipefail
is set):
! cat | tee /dev/full
Or use a command group to negate a single stage:
cat | { ! tee /dev/full; }
POSIX specifies that a status negation operator !
is only used to negate the status of an entire pipeline, not individual stages.
By default the status of a pipeline is that of the last command, so use !
in front of the pipeline to negate as necessary.
If you have set the option pipefail
to OR the status of each stage together, and want to negate the status of only a single stage, you can use negate inside a { ! command group; }
.
Ksh supports !
in front of individual pipeline stages. ShellCheck does not warn when the shebang declares that the script will run with Ksh.
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!