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 done It turns out, this is due to the following line in my .bashrc: MAILCHECK=no I can't even remember putting that in there. Here's what the man page says: MAILCHECK Specifies how often (in seconds) bash checks for mail. The de‐ fault is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking. Apparently "not a number greater than or equal to zero" must not mean what I thought it meant, at the time I wrote that line. At some point, bash must have given MAILCHECK the "integer attribute", which means that MAILCHECK=no is attempting assignment to an *arithmetic* variable, which means it performs a recursive expansion on the word "no" in an arithmetic context -- which makes it treat "no" as a shell variable to be expanded. Hence the complaint from -u. Without -u, and without a "no" variable, the effect is basically MAILCHECK=0 which is clearly not what I wanted. Fortunately, it's entirely moot, because in context, I have this: MAILCHECK=no unset MAILCHECK # Takes too damned long. I guess I should just comment out the first line, then. There's no point keeping it there. So, today I guess I learned that MAILCHECK gained the integer attribute at some point. I wonder when... well, let's find out. ... unicorn:~$ bash-3.1 -uic : bash-3.1: no: unbound variable unicorn:~$ bash-3.0 -uic : unicorn:~$ Looks like it happened in bash 3.1. *Now* I'll comment out that line in my .bashrc.