supuner

RSS feed: whole site

supuner (SUPpress UNless ERror) executes a command and manipulates its stderr and stdout. By default, it captures both stderr and stdout and only outputs their combined value to stdout if the command fails. supuner is useful for chatty commands whose output is only relevant if the command fails.

Download and docs

Latest release: supuner-0.3 (2024-03-08)

  • Better cross-platform installation (e.g. respecting DESTDIR). The Makefile now requires gmake.

  • Various suggestions from shellcheck.

  • Clarify why -e is forbidden unless -o is also specified.

All releases

Repository (issues, PRs, etc.)

Man page for the latest release

Similar programs

Usage

supuner [-e] [-o <filename>] <command>

Options:

-eIf -o is specified, then as well as sending output to a file, echo
stdout and stderr combined to stdout
-o <filename>Send stdout and stderr to file.

supuner exits with the exit code of command.

Examples

Here are examples of the basic styles of use of supuner:

$ supuner ls /bin/sh
$ supuner ls /bin/sh /doesntexist
ls: /doesntexist: such file or directory
/bin/sh
$ supuner -o /tmp/o ls /bin/sh /doesntexist
$ echo $?
1
$ cat /tmp/o
ls: /doesntexist: such file or directory
/bin/sh
$ supuner -e -o /tmp/o ls /bin/sh /doesntexist
ls: /doesntexist: such file or directory
/bin/sh
$ echo $?
1
$ cat /tmp/o
ls: /doesntexist: such file or directory
/bin/sh

Using the fact that supuner exits with the exit code of command, one can use the || operator to perform actions on the combined stdout / stderr output, for example:

$ supuner -o /tmp/o ls /bin/sh /doesntexist \
  || mail -s "Error from ls" somebody@example.com < /tmp/o