Re: SHELLOPTS environment variable causes shell options to cascade

2025-01-06 Thread Wiley Young
On Jan 05 2025, Tobi Laskowski wrote: > "It may be safe, however, it is a bit tedious... Wow. I remember once I corrected an obvious flaw in a major project's CICD bash scripts involving quoting and the trap builtin. You'd have thought I'd have tried to chop somebody's fingers off. Wiley

Re: SHELLOPTS environment variable causes shell options to cascade

2025-01-06 Thread Tobi Laskowski
> | It is not possible to have a naive SHELLOPTS=myopt configured outside > | the shell without all future options being exported implicitly. > I have never used SHELLOPTS, and have never tested this, but: > Does "unset SHELLOPTS" not work? It gives: bash: unset: SHELLOPTS: cannot unset

Re: SHELLOPTS environment variable causes shell options to cascade

2025-01-06 Thread Chet Ramey
On 1/5/25 6:17 AM, Tobi Laskowski wrote: This does not cover the specific behaviour I am concerned with. I would expect something like: "Additionally, if it is in the environment at start up, the variable is automatically exported and shell options enabled subsequently through other means wil

Re: SHELLOPTS environment variable causes shell options to cascade

2025-01-06 Thread Chet Ramey
On 1/4/25 2:47 PM, Tobi Laskowski wrote: Hello, I'd like to ask about an odd behaviour relating to the SHELLOPTS environment variable. This is present in version 5.2.37(1)-release and in the development version. It's the behavior of every bash version going back to bash-2.0. In this case,

Re: SHELLOPTS environment variable causes shell options to cascade

2025-01-06 Thread Chet Ramey
On 1/5/25 5:10 AM, Koichi Murase wrote: I confirmed this behavior, which I think is unreasonable. $ (export SHELLOPTS; set -u; bash +u -c 'echo $unset') bash: line 1: unset: unbound variable I think an option explicitly specified in the command-line arguments should take precedence over

Re: SHELLOPTS environment variable causes shell options to cascade

2025-01-06 Thread Chet Ramey
On 1/5/25 8:09 AM, Robert Elz wrote: Date:Sun, 5 Jan 2025 11:17:05 + From:Tobi Laskowski Message-ID: | It is not possible to have a naive SHELLOPTS=myopt configured outside | the shell without all future options being exported implicitly. I have neve

Re: SHELLOPTS environment variable causes shell options to cascade

2025-01-06 Thread Chet Ramey
On 1/5/25 5:13 AM, Oğuz wrote: Maybe. I'm not sure if propagating shell options to child shells was the intended primary use. It was a long time ago (1995), but yes, that was one of the primary use cases. With ENV/BASH_ENV you can already do that and more, I don't see the point in adding an

Re: SHELLOPTS environment variable causes shell options to cascade

2025-01-06 Thread Chet Ramey
On 1/5/25 3:59 AM, Martin D Kealey wrote: On Sun, 5 Jan 2025 at 15:18, Oğuz wrote: This is documented in the manual: In other words, it's broken by design. You seem awfully sure of the correctness of your opinion. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer