[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tarsnap fails with broken pipe in systemd timer unit
On Tue, Oct 08, 2019 at 01:00:48PM -0700, Colin Percival wrote:
> Why your shell cares about tarsnap's exit code, I don't know; normal POSIX
> shells ignore the exit codes from processes other than the last one in a
> pipeline. Maybe systemd launches bash with some weird "don't behave the way
> that shells are supposed to behave" flags.
There's common advice to run bash scripts with:
set -euxo pipefail
where `-o pipefail` checks the exit code of each command and bails if it's
non-zero. (Or rather: it stops the pipe and sets the exit code of the whole
pipe to that non-zero code; if -e is set, then the whole script bails.)
I couldn't find any evidence that systemd is setting this automatically,
though. But if the original script runs in the shell itself but not as a
systemd service, that's where my suspicion lies.
Cheers,
- Graham