From: Martin Vaeth <martin@mvath.de>
To: zsh-users@zsh.org
Subject: Re: Avoiding the zshells intelligence...in one case
Date: Tue, 24 Jan 2017 19:37:45 +0000 (UTC) [thread overview]
Message-ID: <slrno8fb8e.3dr.martin@lounge.imp.fu-berlin.de> (raw)
In-Reply-To: <alpine.LRH.2.00.1701231438190.4560@toltec.zanshin.com>
Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> You could try this, but it's potentially risky:
>
> re_nomatch() { { ${~@} } always { setopt nomatch } }
> alias t='setopt nonomatch && noglob re_nomatch echo'
Why is this risky? Because it can leave nomatch in the wrong state?
The following does not have this problem and also takes the other
settings you mentioned into account:
unsetopt_nomatch() {
if unsetopt | grep -q nonomatch
then restore_nomatch() setopt nomatch
else restore_nomatch() :
fi
unsetopt nomatch
}
noexpand_restore_nomatch() { {
() {
setopt local_options no_nullglob n_ocshnullglob
${~@}
} $@ } always {
restore_nonomatch
unfunction restore_nomatch
} }
alias noexpand='unsetopt_nomatch; noglob noexpand_restore_nomatch '
Example usage: alias wget='noexpand wget'
It is clumsy, because the "setopt nomatch" must possibly be excluded from
the "localoptions" range; except for using an anonymous function
and passing the arguments to it, I did not find another solution...
To get correct completion for the above alias, I guess you also have to
compdef noexpand_restore_nomatch=noglob
after the initialization of the completion system.
next prev parent reply other threads:[~2017-01-24 19:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-22 8:01 Meino.Cramer
2017-01-22 18:26 ` Bart Schaefer
2017-01-22 21:52 ` Martin Vaeth
2017-01-22 22:41 ` Bart Schaefer
2017-01-23 18:09 ` Martin Vaeth
2017-01-23 22:26 ` Bart Schaefer
2017-01-23 22:40 ` Ray Andrews
2017-01-24 2:48 ` Eric Cook
2017-01-24 5:42 ` Ray Andrews
2017-01-24 15:58 ` Eric Cook
2017-01-24 18:21 ` Ray Andrews
2017-01-24 22:31 ` Bart Schaefer
2017-01-25 1:19 ` Ray Andrews
2017-01-25 3:46 ` Bart Schaefer
2017-01-25 5:40 ` Ray Andrews
2017-01-25 16:50 ` Bart Schaefer
2017-01-25 4:56 ` Bart Schaefer
2017-01-25 5:47 ` Ray Andrews
2017-01-23 22:44 ` Bart Schaefer
2017-01-24 19:37 ` Martin Vaeth [this message]
2017-01-24 21:24 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=slrno8fb8e.3dr.martin@lounge.imp.fu-berlin.de \
--to=martin@mvath.de \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).