On Fri, Aug 26, 2022 at 08:17:10AM +0100, Tim Woodall wrote: > $ cat Makefile.test > SHELL := /bin/bash -u > MAKEFLAGS += --no-builtin-rules > .SUFFIXES: > > all: > echo done > $ make -f Makefile.test > echo done > done > $ make -f Makefile.test | cat > echo done > /etc/bash.bashrc: line 7: PS1: unbound variable ^^^^^^^^^^^
[...] > Why do I get that unbound variable error? (I know how to fix it, I just > don't understand why it only happens when I pipe the output) If I were you, I'd go looking at your /etc/bashrc and see what's around line 7. Mine says (line numbers added by me): 6 # If not running interactively, don't do anything 7 [ -z "$PS1" ] && return ...and indeed, bash -u complains there, because it tries to expand an (unset) PS1 before checking it for emptyness. > And is this a bug? In make? Arguably it's a bug(let) in /etc/bash.bashrc. This would work better: [ -z "${PS1:-}" ] && return But I'll defer to more shell-savvy people for a proper fix. > The only way I've managed to reproduce this other than as above is by > explictly sourcing /etc/bash.bashrc where there are a few places where > set -u can report unbound variables. I think this /is/ what you are seeing. Cheers -- t
signature.asc
Description: PGP signature