zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: run-help and \cmd (was: Simple Tip of the Day)
Date: Tue, 1 Nov 2005 18:23:22 +0000	[thread overview]
Message-ID: <20051101182322.2c31770f.pws@csr.com> (raw)
In-Reply-To: <EXCHANGE0314UikKd2V0000965e@exchange03.csr.com>

Peter Stephenson <pws@csr.com> 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 @@
 fi
 
 # 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
+fi
 
 while ((i++ < $#places))
 do
     what=$places[$i]
+    [[ -n $noalias && $what = *" is an alias "* ]] && continue
     builtin print -r $what
     case $what in
     (*( is an alias)*)


-- 
Peter Stephenson <pws@csr.com>                  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


  reply	other threads:[~2005-11-01 18:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-28 11:11 Simple Tip of the Day zzapper
2005-10-28 11:32 ` Jean Chalard
2005-10-28 15:25   ` Bart Schaefer
2005-10-28 17:40     ` Jean Chalard
2005-10-28 15:53   ` zzapper
2005-10-28 11:47 ` Hannu Koivisto
2005-10-28 12:26   ` Nikolai Weibull
2005-10-29 12:37   ` Konstantin Sobolev
2005-10-29 14:52     ` Christian Taylor
2005-11-01 16:55       ` run-help and \cmd (was: Simple Tip of the Day) Vincent Lefevre
2005-11-01 18:02         ` Peter Stephenson
2005-11-01 18:23           ` Peter Stephenson [this message]
2005-11-01 18:55           ` Vincent Lefevre
2005-10-28 20:08 ` Simple Tip of the Day DervishD
2005-10-30  5:10 ` Philippe Troin
2005-11-01 16:58   ` Vincent Lefevre

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=20051101182322.2c31770f.pws@csr.com \
    --to=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /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).