Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: avoid interpretation of special characters
- X-seq: zsh-users 12297
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: Eric Smith <es@xxxxxxxxxxxx>
- Subject: Re: avoid interpretation of special characters
- Date: Thu, 6 Dec 2007 10:29:29 +0000
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <20071206101149.GA10394@xxxxxxxxxxxx>
- Mail-followup-to: Eric Smith <es@xxxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Embedded Computing Emerson Network Power
- References: <20071206101149.GA10394@xxxxxxxxxxxx>
On Thu, Dec 06, 2007 at 11:11:49AM +0100, Eric Smith wrote:
> For my command (say mut), I want to avoid shell interpretation of
> characters like ~ and > or <
> so when I go mut ~f foo and ~r <2w ~r >1w
> I want those characters passed literally to the script.
> (instead of obviously have to use backslash or quotes for this
> purpose.
[...]
Does that include spaces. Do you want everything past the first
space to be passed to "mut" in one single argument?
you could do something like:
alias mut=':;#'
setopt interactivecomments
check-for-mut() {
if [[ $1 = "mut "* ]]; then
command mut "${1#mut }"
fi
}
preexec_functions+=(check-for-mut)
(not tested).
Alternatively, you could redefine the accept-line widget so that
it inserts quotes were needed.
accept-line() {
if [[ $BUFFER = "mut "* ]]; then
BUFFER="mut ${(qq)BUFFER#mut }"
fi
zle .accept-line
}
zle -N accept-line
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author