Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Reasons for not wanting EXTENDED_GLOB interactively



On Oct 8, 10:15am, Andrej Borsenkow wrote:
> Subject: RE: Reasons for not wanting EXTENDED_GLOB interactively
> >
> >         rm .#*
> 
> Wow! I often use some patterns with exclusion and like so I have
> extended_glob on ... Peter, how hard is to implement globbing modifier
> to turn extended_glob on (and, may be, off)? Something like (#e)... ??

We discussed this once before ... globbing modifiers only work when you
already have extended-glob turned on in the first place, so you can't
make a modifier to turn it on.  And making a modifier to turn it off
doesn't help very much, because if you remember that you need to turn it
off then you can usually remember to use \# or whatever.

One approach to turning it on would be a precmmand modifier, sort of the
reverse of "noglob":

    extglob rm (#i)makefile*~*.am

You can actually write this yourself as a combination shell function and
alias, like this:

function ext_glob {
    setopt localoptions extendedglob
    local command="$1"
    shift
    $==command $==~*			# redo globbing on arguments
}
alias extglob='noglob ext_glob '	# delay globbing until inside

(Note trailing space in the alias, which applies alias expansion to the
word that comes after it so $command will be correct.)

Then just leave extendedglob unset and use extglob when you need it.  (I
should have thought of this years ago; I've been using a little function
named "show" to pre-generate an array named $show that's the result of an
extended glob, and then run e.g. "rm $show".)



Messages sorted by: Reverse Date, Date, Thread, Author