Skip to main content
example of piping to source does not work
Source Link
Nathan
  • 131
  • 4

An alternative to using process substitution is to use /dev/stdin as the file arg so that pipes work as expected:

set -o pipefail
datE | cat /dev/stdin

The above example is a bit contrived since cat will read from stdin if not given a file arg but there are sometime situations where this is necessary like sourcing env variables from. It's useful when a command that may fail:must be given a file.

set -a
sops -d secrets.env | source /dev/stdin

An alternative to using process substitution is to use /dev/stdin as the file arg so that pipes work as expected:

set -o pipefail
datE | cat /dev/stdin

The above example is a bit contrived since cat will read from stdin if not given a file arg but there are sometime situations where this is necessary like sourcing env variables from a command that may fail:

set -a
sops -d secrets.env | source /dev/stdin

An alternative to using process substitution is to use /dev/stdin as the file arg so that pipes work as expected:

set -o pipefail
datE | cat /dev/stdin

The above example is a bit contrived since cat will read from stdin if not given a file arg. It's useful when a command must be given a file.

Source Link
Nathan
  • 131
  • 4

An alternative to using process substitution is to use /dev/stdin as the file arg so that pipes work as expected:

set -o pipefail
datE | cat /dev/stdin

The above example is a bit contrived since cat will read from stdin if not given a file arg but there are sometime situations where this is necessary like sourcing env variables from a command that may fail:

set -a
sops -d secrets.env | source /dev/stdin