On Wed, Sep 24, 2025 at 07:24:37 -0600, Stan Marsh wrote:
> So, really, all that's needed is:
> 
> shopt -q extglob || extoff=Y
> shopt -s extglob
> # Do stuff here
> [ "$extoff" ] && shopt -u extglob

You'll need to intialize extoff to the empty string beforehand.

However, looking at all this, I do have wonder *where* such a piece
of code would be useful.  You can't use it inside a function; extglob
has to be defined before the function is parsed.  If you're writing a
script, then you don't need to investigate the state and preserve it;
you just set it to whatever state you want at the top of the script
and leave it alone.

The only place I can think of where this might *conceivably* be useful
is in a sourced file.

  • why &q... Jean-Jacques Brucker
    • R... Chris Elvidge
      • ... Chris Elvidge
    • R... 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
    • R... Andreas Schwab
      • ... Jean-Jacques Brucker
  • Re: wh... Stan Marsh
    • R... Greg Wooledge

Reply via email to