bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why "shopt -p" sometime return non-zero ?


From: Greg Wooledge
Subject: Re: why "shopt -p" sometime return non-zero ?
Date: Wed, 24 Sep 2025 09:49:13 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]