Re: Weird set -u error

2022-08-28 Thread Tim Woodall
On Fri, 26 Aug 2022, Tim Woodall wrote: $ cat Makefile.test ... Many thanks everybody for all of the help understanding this. Not this exact issue but effectively the same was reported in bug #944780 and the unbound variable in /etc/bash.bashrc was reported in #941248 I've now submitted a

Re: Weird set -u error

2022-08-27 Thread David
On Sun, 28 Aug 2022 at 01:30, Greg Wooledge wrote: > On Sun, Aug 28, 2022 at 12:46:17AM +1000, David wrote: > > I think there might be one remaining aspect still mysterious, so there > > might be yet another factor beyond the FIVE you identified ... > > > > The fact that this statement, first sho

Re: Weird set -u error

2022-08-27 Thread Greg Wooledge
On Sun, Aug 28, 2022 at 12:46:17AM +1000, David wrote: > I think there might be one remaining aspect still mysterious, so there > might be yet another factor beyond the FIVE you identified ... > > The fact that this statement, first shown by Tim, does NOT error: > > $ ( bash -uc : ; : ) (insid

Re: Weird set -u error

2022-08-27 Thread David
On Sun, 28 Aug 2022 at 00:17, Greg Wooledge wrote: > On Sat, Aug 27, 2022 at 09:52:11AM -0400, Greg Wooledge wrote: > > I also can't explain this (still inside the ssh localhost session): > > > > unicorn:~$ (bash -c 'declare -p PS1') > > declare -- PS1="\\h:\\w\\\$ " > > unicorn:~$ (bash -cu 'dec

Re: Weird set -u error

2022-08-27 Thread Greg Wooledge
On Sat, Aug 27, 2022 at 09:52:11AM -0400, Greg Wooledge wrote: > I also can't explain this (still inside the ssh localhost session): > > > unicorn:~$ (bash -c 'declare -p PS1') > declare -- PS1="\\h:\\w\\\$ " > unicorn:~$ (bash -cu 'declare -p PS1') > /etc/bash.bashrc: line 7: PS1: unbound variab

Re: Weird set -u error

2022-08-27 Thread Greg Wooledge
On Sat, Aug 27, 2022 at 05:12:57PM +1000, David wrote: > I have modified my ssh environment so that it is not the default. > But I do see a similar error message, using ssh from stable Debian 11. > > [david@kablamm ~]$ ( bash -cu : ) > [david@kablamm ~]$ ssh kablamm > Linux kablamm 5.10.0-16-amd64

Re: Weird set -u error

2022-08-27 Thread Greg Wooledge
On Sat, Aug 27, 2022 at 12:11:47AM -0500, David Wright wrote: > On Sat 27 Aug 2022 at 00:23:10 (-0400), gene heskett wrote: > > On 8/26/22 20:35, David wrote: > > > On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: > > > > I get these results as well, with Debian 11's packaged bash. > > > Yeah, s

Re: Weird set -u error

2022-08-27 Thread David
On Sat, 27 Aug 2022 at 16:49, Tim Woodall wrote: > This just gets weirder and weirder. > > It looks like it's related to logging in with ssh: [..] > apt-mirror@aptmirror17:~$ ( bash -cu : ) > apt-mirror@aptmirror17:~$ > apt-mirror@aptmirror17:~$ ssh aptmirror17 > Last login: Sat Aug 27 06:23:1

Re: Weird set -u error

2022-08-27 Thread tomas
On Sat, Aug 27, 2022 at 07:49:17AM +0100, Tim Woodall wrote: > On Sat, 27 Aug 2022, to...@tuxteam.de wrote: > > > On Sat, Aug 27, 2022 at 11:22:09AM +1000, David wrote: > > > On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: > > > > > > > Has anyone managed to reproduce the OP's results, either

Re: Weird set -u error

2022-08-26 Thread Tim Woodall
On Sat, 27 Aug 2022, to...@tuxteam.de wrote: On Sat, Aug 27, 2022 at 11:22:09AM +1000, David wrote: On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: Has anyone managed to reproduce the OP's results, either getting "interactive" from a bash -c call, or seeing *any* evidence that /etc/bash.b

Re: Weird set -u error

2022-08-26 Thread David
On Sat, 27 Aug 2022 at 15:07, wrote: > On Sat, Aug 27, 2022 at 11:22:09AM +1000, David wrote: > > On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: > > > Has anyone managed to reproduce the OP's results, either getting > > > "interactive" from a bash -c call, or seeing *any* evidence that > > >

Re: Weird set -u error

2022-08-26 Thread David Wright
On Sat 27 Aug 2022 at 00:23:10 (-0400), gene heskett wrote: > On 8/26/22 20:35, David wrote: > > On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: > > > I get these results as well, with Debian 11's packaged bash. > > Yeah, sorry, I forgot to include, for the record: > > > > $ echo $BASH_VERSION

Re: Weird set -u error

2022-08-26 Thread tomas
On Sat, Aug 27, 2022 at 11:22:09AM +1000, David wrote: > On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: > > > Has anyone managed to reproduce the OP's results, either getting > > "interactive" from a bash -c call, or seeing *any* evidence that > > /etc/bash.bashrc or ~/.bashrc is sourced from

Re: Weird set -u error

2022-08-26 Thread tomas
On Sat, Aug 27, 2022 at 10:32:06AM +1000, David wrote: > On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: > > On Sat, Aug 27, 2022 at 10:21:08AM +1000, David wrote: > > > > Just sharing something that I tried, to shed some more light > > > on this, in case that's useful ... > > > > > > $ foo()

Re: Weird set -u error

2022-08-26 Thread gene heskett
On 8/26/22 20:35, David wrote: On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: On Sat, Aug 27, 2022 at 10:21:08AM +1000, David wrote: Just sharing something that I tried, to shed some more light on this, in case that's useful ... $ foo() { case "$-" in *i* ) i=interactive ;; * ) i=not-inte

Re: Weird set -u error

2022-08-26 Thread David
On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: > Has anyone managed to reproduce the OP's results, either getting > "interactive" from a bash -c call, or seeing *any* evidence that > /etc/bash.bashrc or ~/.bashrc is sourced from a bash -c call? On Debian 11, when I create a test user, login

Re: Weird set -u error

2022-08-26 Thread David
On Sat, 27 Aug 2022 at 10:27, Greg Wooledge wrote: > On Sat, Aug 27, 2022 at 10:21:08AM +1000, David wrote: > > Just sharing something that I tried, to shed some more light > > on this, in case that's useful ... > > > > $ foo() { case "$-" in *i* ) i=interactive ;; * ) i=not-interactive ;; > > es

Re: Weird set -u error

2022-08-26 Thread Greg Wooledge
On Sat, Aug 27, 2022 at 10:21:08AM +1000, David wrote: > Just sharing something that I tried, to shed some more light > on this, in case that's useful ... > > $ foo() { case "$-" in *i* ) i=interactive ;; * ) i=not-interactive ;; > esac ; echo $BASHPID $i ; } > $ declare -fx foo > $ foo > 2415 int

Re: Weird set -u error

2022-08-26 Thread David
On Sat, 27 Aug 2022 at 08:54, Tim Woodall wrote: > On Fri, 26 Aug 2022, to...@tuxteam.de wrote: > > On Fri, Aug 26, 2022 at 10:57:44AM -0400, Greg Wooledge wrote: > I modified /etc/bash.bashrc to prove it was only being sourced in the > second case above (it prints the value of PS1) > > And now I

Re: Weird set -u error

2022-08-26 Thread Greg Wooledge
On Fri, Aug 26, 2022 at 11:54:06PM +0100, Tim Woodall wrote: > I modified /etc/bash.bashrc to prove it was only being sourced in the > second case above (it prints the value of PS1) > > And now I can reproduce without -u > $ bash -c : > $ ( bash -c : ) > 'PS1=' > $ ( bash -c : ; : ) > $ I can't r

Re: Weird set -u error

2022-08-26 Thread Tim Woodall
On Fri, 26 Aug 2022, to...@tuxteam.de wrote: On Fri, Aug 26, 2022 at 10:57:44AM -0400, Greg Wooledge wrote: [...] There are also various hacks that are compiled into Debian's version of bash [...] At this moment, I'm kind of leaning toward one of those hacks being triggered by your specifi

Re: Weird set -u error

2022-08-26 Thread tomas
On Fri, Aug 26, 2022 at 10:57:44AM -0400, Greg Wooledge wrote: [...] > There are also various hacks that are compiled into Debian's version > of bash [...] > At this moment, I'm kind of leaning toward one of those hacks being > triggered by your specific combination of factors. That's the most

Re: Weird set -u error

2022-08-26 Thread Greg Wooledge
On Fri, Aug 26, 2022 at 02:51:47PM +0100, Tim Woodall wrote: > The real Makefile has -euo pipefail I have stopped reading and caring now. Good luck.

Re: Weird set -u error

2022-08-26 Thread Greg Wooledge
On Fri, Aug 26, 2022 at 02:40:55PM +0100, Tim Woodall wrote: > But that's backwards, make is starting an interactive shell when its > output is redirected. When I don't redirect make's output it works. I thought you were piping in the original message. There is a difference between a pipe, and a

Re: Weird set -u error

2022-08-26 Thread David
On Fri, 26 Aug 2022 at 23:41, Tim Woodall wrote: > On Fri, 26 Aug 2022, David wrote: > > On Fri, 26 Aug 2022 at 22:14, wrote: > >> And then, there's that other riddle: why is a shell invoked from a > >> Makefile sourcing /etc/bash.bashrc in the first place? > > > > Hi, my understanding is that t

Re: Weird set -u error

2022-08-26 Thread Tim Woodall
On Fri, 26 Aug 2022, David wrote: On Fri, 26 Aug 2022 at 22:14, wrote: On Fri, Aug 26, 2022 at 07:24:44AM -0400, Greg Wooledge wrote: On Fri, Aug 26, 2022 at 08:17:10AM +0100, Tim Woodall wrote: [...] On Fri, Aug 26, 2022 at 11:04:25AM +0200, Thomas Schmitt wrote: to...@tuxteam.de wrote:

Re: Weird set -u error

2022-08-26 Thread Tim Woodall
On Fri, 26 Aug 2022, David wrote: On Fri, 26 Aug 2022 at 22:14, wrote: And then, there's that other riddle: why is a shell invoked from a Makefile sourcing /etc/bash.bashrc in the first place? Hi, my understanding is that the rule commands in the Makefile are run by a shell, one for each li

Re: Weird set -u error

2022-08-26 Thread David
On Fri, 26 Aug 2022 at 22:14, wrote: > On Fri, Aug 26, 2022 at 07:24:44AM -0400, Greg Wooledge wrote: > > On Fri, Aug 26, 2022 at 08:17:10AM +0100, Tim Woodall wrote: [...] > > On Fri, Aug 26, 2022 at 11:04:25AM +0200, Thomas Schmitt wrote: > > > to...@tuxteam.de wrote: > But all in all we're s

Re: Weird set -u error

2022-08-26 Thread David
On Fri, 26 Aug 2022 at 22:14, wrote: > And then, there's that other riddle: why is a shell invoked from a > Makefile sourcing /etc/bash.bashrc in the first place? Hi, my understanding is that the rule commands in the Makefile are run by a shell, one for each line. The output stream of those comm

Re: Weird set -u error

2022-08-26 Thread tomas
On Fri, Aug 26, 2022 at 07:24:44AM -0400, Greg Wooledge wrote: > On Fri, Aug 26, 2022 at 08:17:10AM +0100, Tim Woodall wrote: > > $ cat Makefile.test > > SHELL := /bin/bash -u > > WHY?! > > > Why do I get that unbound variable error? > > Because you turned on set -u in a place where the code had

Re: Weird set -u error

2022-08-26 Thread Greg Wooledge
On Fri, Aug 26, 2022 at 11:14:37AM +0100, Tim Woodall wrote: > $ bash -uic 'echo done' > bash: SUDO_USER: unbound variable > bash: color_prompt: unbound variable > done > $ Cute. Mine's even weirder: unicorn:~$ bash -uic 'echo done' bash: SUDO_USER: unbound variable bash: no: unbound variable do

Re: Weird set -u error

2022-08-26 Thread Greg Wooledge
On Fri, Aug 26, 2022 at 08:17:10AM +0100, Tim Woodall wrote: > $ cat Makefile.test > SHELL := /bin/bash -u WHY?! > Why do I get that unbound variable error? Because you turned on set -u in a place where the code had not been adjusted to account for set -u's foibles. set -u breaks scripts. It's

Re: Weird set -u error

2022-08-26 Thread Tim Woodall
On Fri, Aug 26, 2022 at 09:19:03AM +0100, Tim Woodall wrote: [...] Yes, I know how to fix it. That is straight forward. SUDO_USER and SUDO_PS1 have similar issues, debian_chroot works in the presence of set -u I see. But I don't understand why /etc/bash.bashrc is being sourced by make w

Re: Weird set -u error

2022-08-26 Thread David
On Fri, 26 Aug 2022 at 18:02, wrote: > 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

Re: Weird set -u error

2022-08-26 Thread tomas
On Fri, Aug 26, 2022 at 11:04:25AM +0200, Thomas Schmitt wrote: > Hi, > > to...@tuxteam.de wrote: > > Why {PS1:+x} rather than {PS1:-}? > > It seemed to be the nearest suitable variation which was similar to the > proposal > [ ${var+x} ] [...] Thanks :) Cheers -- t signature.asc Descripti

Re: Weird set -u error

2022-08-26 Thread Thomas Schmitt
Hi, to...@tuxteam.de wrote: > Why {PS1:+x} rather than {PS1:-}? It seemed to be the nearest suitable variation which was similar to the proposal [ ${var+x} ] in https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash where one can see a nice table of ${VARIABLE.

Re: Weird set -u error

2022-08-26 Thread tomas
On Fri, Aug 26, 2022 at 09:19:03AM +0100, Tim Woodall wrote: [...] > Yes, I know how to fix it. That is straight forward. SUDO_USER and > SUDO_PS1 have similar issues, debian_chroot works in the presence of set > -u I see. > But I don't understand why /etc/bash.bashrc is being sourced by make >

Re: Weird set -u error

2022-08-26 Thread Tim Woodall
On Fri, 26 Aug 2022, to...@tuxteam.de wrote: 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 /

Re: Weird set -u error

2022-08-26 Thread tomas
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 f

Re: Weird set -u error

2022-08-26 Thread tomas
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

Re: Weird set -u error

2022-08-26 Thread Thomas Schmitt
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 r