Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Something like noglob to inhibit brace expansion?
- X-seq: zsh-users 6650
- From: Lloyd Zusman <ljz@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Something like noglob to inhibit brace expansion?
- Date: Mon, 06 Oct 2003 10:12:40 -0400
- In-reply-to: <1031005162121.ZM2735@xxxxxxxxxxxxxxxxxxxxxxx> (Bart Schaefer's message of "Sun, 5 Oct 2003 16:21:21 +0000")
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <m3wubkmv0y.fsf@xxxxxxxxxx> <1031005162121.ZM2735@xxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: ljz@xxxxxxxxxx
- Sender: Lloyd Zusman <ljz@xxxxxxxxxx>
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:
> On Oct 4, 7:40pm, Lloyd Zusman wrote:
> }
> } % pr {a,b,c,*}
> } a b c *
> }
> } What I'd like to see is {a,b,c,*}
> }
> } Does anyone know of any tricks to get this functionality within
> } an alias?
>
> It's a little ugly, but:
>
> alias pr='setopt noglob ignorebraces && _pr'
> _pr() { print $*; setopt glob braceexpand }
>
> You can get a little fancier if you want to preserve the exit status of
> 'print', but you get the idea.
Aha! Thank you.
And I think that the following will take care of the exit code:
alias pr='setopt noglob ignorebraces && _pr'
_pr() { print $*; local rc=$?; setopt glob braceexpand; return $rc }
Hmm ... or what about this as an even uglier alternative (one long
line in real life)?
alias pr='eval "preexec() { setopt braceexpand; preexec(){} }" &&
setopt ignorebraces && noglob print'
There's even probably some sort of way to make a generic alias or
function for this, which can then be applied to any command to generate
an alias for it without command-line expansion. Next time I have
trouble sleeping at night, I'll work on that one. :)
Feature suggestion: how about adding an 'ignorebraces' precommand
modifier in a future version of zsh? Or perhaps even something which
would pass in the completely unglobbed, unexpanded, un-everything'ed
command line. Or even more radically, how about an 'ignore' precommand
modifier which takes options that can be grouped together, such as -b
for braces, -g for glob, -v for variable expansion, etc.?
--
Lloyd Zusman
ljz@xxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author