On Fri, Aug 26, 2022 at 10:01:06AM +0200, Thomas Schmitt wrote:
> Hi,
>
> > $ cat Makefile.test
> > SHELL := /bin/bash -u
> > [...]
> > /etc/bash.bashrc: line 7: PS1: unbound variable
> > [...]
> > Why do I get that unbound variable error?
>
> According to a comment in /etc/bash.bashrc it tests for emptiness of PS1
> in order to detect non-interactive shell sessions:
>
> # If not running interactively, don't do anything
> [ -z "$PS1" ] && return
>
> See
> https://sources.debian.org/src/bash/5.2~rc2-2/debian/etc.bash.bashrc/#L6
>
>
> It should rather test for the variable being set, rather than being empty.
>
> Jumping ahead of more skilled experts i found in the web
> https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
> which brings me to a proposal for /etc/bash.bashrc
>
> [ -z "${PS1:+x}" ] && return
[...]
Ah, great minds think alike :)
Why {PS1:+x} rather than {PS1:-}?
(Not a rethorical question: I think I can learn more shell programming
from you than the other way around)
Cheers
--
t
Attachment:
signature.asc
Description: PGP signature