zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: run-help's man arguments
Date: Fri, 05 Jun 2009 12:10:52 +0100	[thread overview]
Message-ID: <2161.1244200252@csr.com> (raw)

I've only recently started using the vanilla run-help supplied with the
shell.  Ages ago, in

http://www.zsh.org/mla/workers//2000/msg01589.html

run-help got changed to invoke "man $@" rather than "man $1".  This was
described as being "to allow the specification of sections and other man
options through" (sic, presumably something missing?)

The text has changed since then, but the basic feature is still there.

Nobody's ever complained about this, but this is surely weird; that's
not how you use run-help, the $@ is the stuff on the command line which
doesn't include anything for "man" unless you type it yourself, which is
rather against the spirit of run-help (and very well hidden).

I ran into this running run-help on

  locate -r stuff

which caused man to barf immediately due to the annoying and confusing
GNU feature that options can occur anywhere on the command line, so -r
is picked up as an option to "man" rather than "locate".  This
particular problem is fixed by

  POSIXLY_CORRECT=1 man $@:t

which is presumably benign for other versions of man so I'll commit it.

However, the original query remains.  Why do we need $@ rather than $1?
Why do I need man to produce the error messages

No manual entry for -r
No manual entry for stuff

?

I can see that help on something like "nice locate -r stuff" (stupid
example) or even "nice -n 10 locate -r stuff" does something sensible
but with some harmless error messages.  Is this the correct rationale?

Index: Functions/Misc/run-help
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/run-help,v
retrieving revision 1.15
diff -u -r1.15 run-help
--- Functions/Misc/run-help	25 Apr 2009 20:30:20 -0000	1.15
+++ Functions/Misc/run-help	5 Jun 2009 11:06:22 -0000
@@ -8,8 +8,7 @@
 #	autoload run-help
 #
 
-emulate -R zsh
-setopt localoptions
+emulate -RL zsh
 
 local HELPDIR="${HELPDIR:-/usr/share/zsh/$ZSH_VERSION/help}"
 
@@ -103,7 +102,7 @@
 		done
 		eval "run-help-$1:t ${(q@)cmd_args[2,-1]}"
 	    else
-		man $@:t
+		POSIXLY_CORRECT=1 man $@:t
 	    fi
 	fi
 	;;
-- 
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


             reply	other threads:[~2009-06-05 11:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-05 11:10 Peter Stephenson [this message]
2009-06-05 15:14 ` Bart Schaefer
2009-06-06  3:52 ` Jun T.
2009-06-06  5:53   ` Bart Schaefer
2009-06-08  8:52     ` Peter Stephenson
2009-06-08 13:54       ` Clint Adams
2009-06-08 14:03         ` Peter Stephenson
2009-06-08 16:06           ` Bart Schaefer
2009-06-08 16:36             ` Peter Stephenson

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=2161.1244200252@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@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).