Surprising behavior with inline environment variable expansion

2025-03-26 Thread Léa Gris
Hello, While experimenting with inline environment variables, I noticed that although they are correctly applied to command execution, their expansion sometimes retains the previous value—but not always! Context: Bash version: GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Andreas Schwab
On Mär 26 2025, Léa Gris wrote: > Even though LC_NUMERIC=C is used to correctly parse 3.141592654, the > expansion of $LC_NUMERIC still prints its original value (fr_FR.UTF-8). That is expected. The reference to LC_NUMERIC is expanded before the command execution is started (which includes putti

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Andreas Kähäri
On Wed, Mar 26, 2025 at 12:19:48PM +0100, Andreas Schwab wrote: > On Mär 26 2025, Léa Gris wrote: > > > Even though LC_NUMERIC=C is used to correctly parse 3.141592654, the > > expansion of $LC_NUMERIC still prints its original value (fr_FR.UTF-8). > > That is expected. The reference to LC_NUMER

Re: ;exit in bash history causes bash to exit

2025-03-26 Thread microsuxx
yea make bug report .. in my experience , such bash codes on github have very low code quality .. peace .. ++ On Wed, Mar 26, 2025, 15:09 Ethan Gascoigne wrote: > I do have an alias with `&& exit` in it, but removing that alias > doesn't get rid of the bug. I've tested it on another system (Xub

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Léa Gris
Le 26/03/2025 à 12:54, Andreas Kähäri wrote : On my Alpine system (bash 5.3.37), LC_NUMERIC is unset, and setting LC_ALL does not automagically set LC_NUMERIC in "bash -c": % LC_ALL=C bash -c 'echo "$LC_NUMERIC"' (blank line output) % LANG=C bash -c 'echo "$LC_NUMERIC"'

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Robert Elz
Date:Wed, 26 Mar 2025 16:05:57 -0400 From:Chet Ramey Message-ID: | There is a precedence hierarchy associated with locale environment | variables, since setting and unsetting environment variables is under | the user's control. This brings up an unrelated, bu

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Chet Ramey
On 3/26/25 6:52 AM, Léa Gris wrote: LANG=C LC_NUMERIC=C printf '%s\t%f\t%f\n' "$LC_NUMERIC" 3.141592654 3,141592654 Outputs: bash: printf: 3,141592654: invalid number fr_FR.UTF-8    3.141593    3.00 In this particular case, the expansion of LC_NUMERIC is performed before the `printf' bu

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Chet Ramey
On 3/26/25 8:20 AM, Léa Gris wrote: I am onto something here : No, not really. It's pretty simple. $ LC_ALL=C bash -c 'locale; printf "\\nEnvironment variable: LC_NUMERIC=%s\ \n" "$LC_NUMERIC"' LC_ALL overrides LC_NUMERIC, as explained in the POSIX reference I sent. Setting LC_ALL doesn't c

Re: ;exit in bash history causes bash to exit

2025-03-26 Thread Dale R. Worley
Ethan Gascoigne writes: > Narrowed it down to the line `eval "$(fasd --init auto)"` in my > .bashrc. Must be some kindof bug with fasd > (https://github.com/whjvenyl/fasd). Any idea how fasd could cause > `;exit` to be interpreted as a valid command? Running `alias exit` > shows that it's not alia

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Chet Ramey
On 3/26/25 7:54 AM, Andreas Kähäri wrote: On my Alpine system (bash 5.3.37), LC_NUMERIC is unset, and setting LC_ALL does not automagically set LC_NUMERIC in "bash -c": % LC_ALL=C bash -c 'echo "$LC_NUMERIC"' (blank line output) % LANG=C bash -c 'echo "$LC_NUMERIC"'

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Chet Ramey
On 3/26/25 8:09 AM, Léa Gris wrote: I wonder if locale is switched accordingly to environment variables, but environment variables may not automatically switch to the new locale. There is a precedence hierarchy associated with locale environment variables, since setting and unsetting environm

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Andreas Kähäri
On Wed, Mar 26, 2025 at 01:35:12PM +0100, Andreas Schwab wrote: > On Mär 26 2025, Andreas Kähäri wrote: > > > The argument to "bash -c" > > There is no "bash -c" in that command. > > -- > Andreas Schwab, SUSE Labs, sch...@suse.de > GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Léa Gris
I am onto something here : $ LC_ALL=C bash -c 'locale; printf "\\nEnvironment variable: LC_NUMERIC=%s\\n" "$LC_NUMERIC"' Output: LANG=fr_FR.UTF-8 LANGUAGE=fr_FR:fr_CA:en LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_PAPER="C" LC_NAME="C" LC_ADDRESS="

Re: Surprising behavior with inline environment variable expansion

2025-03-26 Thread Greg Wooledge
On Wed, Mar 26, 2025 at 13:09:45 +0100, Léa Gris wrote: > $ LC_ALL=C locale > LANG=fr_FR.UTF-8 > LANGUAGE=fr_FR:fr_CA:en > LC_CTYPE="C" > LC_NUMERIC="C" > LC_TIME="C" > LC_COLLATE="C" > LC_MONETARY="C" > LC_MESSAGES="C" > LC_PAPER="C" > LC_NAME="C" > LC_ADDRESS="C" > LC_TELEPHONE="C" > LC_MEASUREME

Re: ;exit in bash history causes bash to exit

2025-03-26 Thread Duncan Roe
On Tue, Mar 25, 2025 at 05:55:23PM -0400, Greg Wooledge wrote: > On Tue, Mar 25, 2025 at 22:16:15 +0100, microsuxx wrote: > > when bash reads exit cmd it will exit > > so bash reads rc and exits .. > > also .. u may have a ';exit' alias .. > > The claim is that the ;exit appears in .bash_history (n