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

Re: run-help and \cmd (was: Simple Tip of the Day)

Peter Stephenson <pws@xxxxxxx> wrote:
> You mean run-help on \ls doesn't work?  The shell doesn't know what the
> run-help alias/function is going to do with the information so provides
> exactly what it got.  Using a more sophisticated version of run-help would
> do the trick; even turning "man $1" into "eval man $1" would work.
> However, that's a little dangerous to have as the default.

Slightly more helpfully, here is the run-help function supplied with the
shell enhanced to strip quotes (and suppress alias lookup for the stripped
word) when that makes a difference.

Index: Functions/Misc/run-help
RCS file: /cvsroot/zsh/zsh/Functions/Misc/run-help,v
retrieving revision 1.4
diff -u -r1.4 run-help
--- Functions/Misc/run-help	2 Apr 2001 13:04:05 -0000	1.4
+++ Functions/Misc/run-help	1 Nov 2005 18:20:50 -0000
@@ -33,15 +33,22 @@
 # No zsh help; use "whence" to figure out where else we might look
-local what places newline='
+local what places noalias newline='
 integer i=0 didman=0
 places=( "${(@f)$(builtin whence -va $1)}" )
+if [[ $places = *"not found"* && $1 != ${(Q)1} ]]; then
+  # Different when unquoted, so try stripping quotes.
+  places=( "${(@f)$(builtin whence -va ${(Q)1})}" )
+  # Quotation is significant to aliases, so suppress lookup.
+  noalias=1
 while ((i++ < $#places))
+    [[ -n $noalias && $what = *" is an alias "* ]] && continue
     builtin print -r $what
     case $what in
     (*( is an alias)*)

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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