Re: SHELLOPTS environment variable causes shell options to cascade
From:
Tobi Laskowski
Subject:
Re: SHELLOPTS environment variable causes shell options to cascade
Date:
Tue, 7 Jan 2025 11:24:12 +0000
> This precdence question is really the only one. Is this issue serious
> enough to change previous behavior in an incompatible way?
To me it seems most intuitive for flags to be applied after the environment
variable, but I do not mind too much about this.
> No. That is not consistent with the historical behavior of SHELLOPTS,
> and not consistent with the behavior of environment variables.
Agreed, thanks for the detailed explanations. I see now that the patch does not
make sense and would only make things more confusing.
> I'm not sure why the setup-ocaml authors chose the method they did, but
> it seems like that's where this issue starts.
Yes, given that there is this side effect of storing what is normally a shell
variable in the environment instead, this does not seem like the correct way to
achieve the goal of a globally set option.
> Maybe they could change things to run `export -n SHELLOPTS' where appropriate.
There is not really a good place to put these `export -n SHELLOPTS` lines in
this case. Users of setup-ocaml would have to add these lines to their bash
scripts which does not seem like a good solution. I think, as you've said, the
issue starts with misusing SHELLOPTS.