Re: SHELLOPTS environment variable causes shell options to cascade
From:
Chet Ramey
Subject:
Re: SHELLOPTS environment variable causes shell options to cascade
Date:
Mon, 6 Jan 2025 09:32:49 -0500
User-agent:
Mozilla Thunderbird
On 1/5/25 8:09 AM, Robert Elz wrote:
Date: Sun, 5 Jan 2025 11:17:05 +0000
From: Tobi Laskowski <tobil4sk@outlook.com>
Message-ID:
<LO6P265MB6347C150FCE01EAC8D194781B1172@LO6P265MB6347.GBRP265.PROD.OUTLOOK.COM>
| 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?
No. It's managed by the shell and readonly. You can remove the export
attribute, though.
It would probably be useful to have that as one of the initial commands
in every script, perhaps after saving its previous value if that is
needed, and then if it is wanted for a sub-shell or exec'd script
set it again, as in:
SHELLOPTS=whatever script
You can't do this; you have to change the options using `set -o'.
SHELLOPTS reflects the current state of the options controllable by
`set -o'.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/