RE: Catching errors in pipes
"Cook, Malcolm" <[email protected]> Tue, 5 Dec 2023 18:54:27 +0000
| Newsgroups | gmane.comp.gnu.make.general |
|---|---|
| Message-ID | <DS7PR20MB4671EE5026F1D208EF46547CBE85A@DS7PR20MB4671.namprd20.prod.outlook.com> |
> Is there a recommended way to catch errors in pipelines of coommands that > are used in recipes, please? I use the following with good success: SHELL=/usr/bin/bash .SHELLFLAGS = -eu -o pipefail -c FWIW: I usually use the above in combination with: .ONESHELL: MAKEFLAGS += --no-builtin-rules MAKEFLAGS += --no-builtin-variables MAKEFLAGS += --output-sync MAKEFLAGS += --warn-undefined-variables .DELETE_ON_ERROR: .SUFFIXES: .SECONDEXPANSION: > If so, how backward-compatible are they? To my knowledge this has always had the same results. > I saw the .SHELLFLAGS variable but also found a bug report saying that its > content is passed to the shell as one single argument. Is it thus mandatory to > prefix every pipeline with set -o pipefail; or is there a more global way to get > the desired behaviour? If you reference this report you might get a reply that considers it.