On 24/09/2025 at 13:10, Jean-Jacques Brucker wrote:
Hello friends,

I met a strange behavior with "shopt -p", which could ruin my sleep .
In a part of a script, i would like to use extglob,
then I wrote:

```
# save extglob shopt
extglob="$(shopt -p extglob)"
# Make sure extglob is set
shopt -s extglob
```
(and later: )
```
# make sure extglob is as we found it before.
$extglob

```

But the line
extglob="$(shopt -p extglob)" )
returns 1.

Why ?

NB: As I use to use "set -e", it is a little annoying, and I won't like to add a dirty 
"|| true" as a workaround.

NB2: Tested on 2 debian machines, bash versions : 5.2.37 and 5.2.15.

```


shopt -p extglob >/dev/null; s_extglob=$?
shopt -s extglob

( do processing )

((s_extglob==1)) && shopt -u extglob


--
Chris Elvidge
England


  • Re: wh... Stan Marsh
    • w... Jean-Jacques Brucker
      • ... Chris Elvidge
        • ... Chris Elvidge
      • ... Duncan Roe via Bug reports for the GNU Bourne Again SHell
        • ... Martin D Kealey
          • ... Jean-Jacques Brucker via Bug reports for the GNU Bourne Again SHell
      • ... Andreas Schwab
        • ... Jean-Jacques Brucker
    • R... Stan Marsh
      • ... Greg Wooledge

Reply via email to