Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to prevent alias expansion
- X-seq: zsh-workers 26244
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: How to prevent alias expansion
- Date: Sun, 04 Jan 2009 10:33:36 -0800
- In-reply-to: <slrngm1n3d.sgm.joerg@xxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <slrngm1n3d.sgm.joerg@xxxxxxxxxxxx>
On Jan 4, 3:57pm, Jorg wrote: }
}
} I've a problem with alias expansion. When using run-help and an global
} alias for redirect to /dev/null the command fails.
}
} % alias -g DN='>/dev/null'
} % git show DN<ESC h>
} <empty output>
}
} I propose this patch:
} - eval "run-help-$1:t ${(q@)cmd_args[2,-1]}"
} + eval "run-help-$1:t ${(qq@)cmd_args[2,-1]}"
Hrm. (qq) is not "quote twice", it's "quote with single quotes", whereas
(q) is "quote with backslashes".
So what's happening here is that quoting with backslashes doesn't change
"DN" at all (because it contains no metacharacters), so then during the
eval, global alias expansion kicks in as usual. Quoting with single
quotes prevents alias expansion and passes (show DN) to run-help-git.
I can't decide what's correct here. Are there are cases where someone
would want such an alias to expand? run-help itself already looks up
aliases on the command word by way of "which". Consequently a more
obvious patch (to a reader of the script) might be:
emulate -R zsh
- setopt localoptions
+ setopt localoptions noaliases
Messages sorted by:
Reverse Date,
Date,
Thread,
Author