zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: Word splitting in parameter expansion
Date: Fri, 02 May 2003 16:56:32 +0100	[thread overview]
Message-ID: <10178.1051890992@csr.com> (raw)
In-Reply-To: "=?iso-8859-1?Q?Bj=F6rn_Lindstr=F6m?="'s message of "Fri, 02 May 2003 17:45:56 +0200." <20030502154556.GA29562@lucien.dreaming>

=?iso-8859-1?Q?Bj=F6rn_Lindstr=F6m?= wrote:
> I've got this in my .zshrc:
> 
>     man() {
>         screen -h 0 -t "man $@" man $@
>     }
> 
> This works fine as long as I only supply the function with one argument,
> such as "man access", but when I do "man 5 access", it interprets
> "5 access" as one argument (even though that is not what I meant ;-).

I don't think it's doing quite what you say (although you don't see what
options you have set), but I agree it won't do what you expect...

If the arguments are `5' and `access' I would expect the words to be
divided as:

screen
-h
0
-t
man 5
access
man
5
access

(which is certainly what I get with my option settings).  The problem is
that the argument to -t is being divided into two parts.  To prevent that
you need:

man() {
    screen -h 0 -t "man $*" man $@
}

Actually, that last argument could be $* as well; if you want to
maintain zero-length arguments it needs to be "$@".

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


  reply	other threads:[~2003-05-02 15:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-02 15:45 Björn Lindström
2003-05-02 15:56 ` Peter Stephenson [this message]
2003-05-02 16:08   ` Lloyd Zusman
2003-05-02 16:14     ` Peter Stephenson
2003-05-02 16:25       ` Lloyd Zusman

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=10178.1051890992@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).