zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Documentation of colon in parameter expansion
Date: Sun, 01 Apr 2007 10:53:59 -0700	[thread overview]
Message-ID: <070401105359.ZM18385@torch.brasslantern.com> (raw)
In-Reply-To: <loom.20070331T224203-896@post.gmane.org>

(Hmm, posting a patch on April Fools' Day might not be the best idea.
Oh, well.)

On Mar 31,  8:51pm, Miciah Dashiel Butler Masters wrote:
}
} I was recently trying to look up the syntax for '${NAME-WORD}'.
} A search for '${NAME:-WORD}' turns up information on that syntax,
} but one must look several paragraphs down to see that '${NAME-WORD}'
} is also allowed and has a distinct meaning.

Suggested patch below.  Line numbers may be off.  Is the new final
paragraph ("In any of the above ...") incorrect in some way?  It used
to only be stated for :- and :+ but I think it applies to := as well.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Doc/Zsh/expn.yo,v
retrieving revision 1.22
diff -c -r1.22 expn.yo
--- expn.yo	1 Oct 2006 02:38:52 -0000	1.22
+++ expn.yo	1 Apr 2007 17:31:29 -0000
@@ -450,39 +486,39 @@
 If var(name) is the name of a set parameter `tt(1)' is substituted,
 otherwise `tt(0)' is substituted.
 )
+xitem(tt(${)var(name)tt(-)var(word)tt(}))
 item(tt(${)var(name)tt(:-)var(word)tt(}))(
-If var(name) is set and is non-null then substitute its
-value; otherwise substitute var(word). If var(name) is
-missing, substitute var(word).
-Note that you can use standard shell quoting in the var(word) value to
-selectively override the splitting done by the tt(SH_WORD_SPLIT) option
-and the tt(=) flag, but not the tt(s:)var(string)tt(:) flag.
+If var(name) is set, or in the second form is non-null, then substitute
+its value; otherwise substitute var(word).  In the second form var(name)
+may be omitted, in which case var(word) is always substituted.
 )
+xitem(tt(${)var(name)tt(PLUS())var(word)tt(}))
+item(tt(${)var(name)tt(:PLUS())var(word)tt(}))(
+If var(name) is set, or in the second form is non-null, then substitute
+var(word); otherwise substitute nothing.
+)
+xitem(tt(${)var(name)tt(=)var(word)tt(}))
 xitem(tt(${)var(name)tt(:=)var(word)tt(}))
 item(tt(${)var(name)tt(::=)var(word)tt(}))(
-In the first form, if var(name) is unset or is null then
-set it to var(word); in the second form, unconditionally
-set var(name) to var(word).  In both forms, the value of
-the parameter is then substituted.
+In the first form, if var(name) is unset then set it to var(word); in the
+second form, if var(name) is unset or null then set it to var(word); and
+in the third form, unconditionally set var(name) to var(word).  In all
+forms, the value of the parameter is then substituted.
 )
+xitem(tt(${)var(name)tt(?)var(word)tt(}))
 item(tt(${)var(name)tt(:?)var(word)tt(}))(
-If var(name) is set and is non-null then substitute
-its value; otherwise, print var(word) and exit from the shell.
-Interactive shells instead return to the prompt.
-If var(word) is omitted, then a standard message is printed.
-)
-item(tt(${)var(name)tt(:PLUS())var(word)tt(}))(
-If var(name) is set and is non-null then substitute
-var(word); otherwise substitute nothing.
-Note that you can use standard shell quoting in the var(word) value to
-selectively override the splitting done by the tt(SH_WORD_SPLIT) option
-and the tt(=) flag, but not the tt(s:)var(string)tt(:) flag.
+In the first form, if var(name) is set, or in the second form if var(name)
+is both set and non-null, then substitute its value; otherwise, print
+var(word) and exit from the shell.  Interactive shells instead return to
+the prompt.  If var(word) is omitted, then a standard message is printed.
 )
 enditem()
 
-If the colon is omitted from one of the above expressions
-containing a colon, then the shell only checks whether
-var(name) is set, not whether its value is null.
+In any of the above expressions that test a variable and substitute an
+alternate var(word), note that you can use standard shell quoting in the
+var(word) value to selectively override the splitting done by the
+tt(SH_WORD_SPLIT) option and the tt(=) flag, but not splitting by the
+tt(s:)var(string)tt(:) flag.
 
 In the following expressions, when var(name) is an array and
 the substitution is not quoted, or if the `tt((@))' flag or the


  reply	other threads:[~2007-04-01 23:21 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-31 20:51 Miciah Dashiel Butler Masters
2007-04-01 17:53 ` Bart Schaefer [this message]
2007-04-01 18:26   ` Peter Stephenson
  -- strict thread matches above, loose matches on Subject: below --
2013-08-30  1:12 mailcap configuration in zsh can't open .bk files vinurs
2013-08-30  2:59 ` Phil Pennock
2013-08-30  3:27   ` shawn wilson
2013-08-30  8:29   ` Peter Stephenson
2013-08-30 17:10     ` Bart Schaefer
2013-09-01 17:11       ` Peter Stephenson
2013-09-02  1:28         ` vinurs
2013-09-02 13:46           ` Peter Stephenson
2013-09-02 17:45             ` Bart Schaefer
2010-08-20 15:35 Synchronous vs. Asynchronous Bart Schaefer
2010-08-20 15:45 ` Peter Stephenson
2010-08-20 17:36   ` Bart Schaefer
2010-08-21 18:41     ` Peter Stephenson
2010-08-21 22:31       ` Vincent Lefevre
2010-08-22  5:02         ` Bart Schaefer
2010-08-22  5:42       ` Bart Schaefer
2010-08-22 17:53         ` Peter Stephenson
     [not found] <1209745744.25440.ezmlm@sunsite.dk>
2008-05-02 17:39 ` Zsh hangs sometimes? Kamil Jońca
2008-05-02 22:44   ` Peter Stephenson
2008-05-03 11:35     ` Bart Schaefer
2008-05-04 12:13       ` Peter Stephenson
2008-05-04 17:00         ` Bart Schaefer
2008-05-04 18:14           ` Peter Stephenson
2008-05-04 20:00             ` Bart Schaefer
2008-05-05 11:54               ` Aaron Davies
2007-09-05 16:34 preexec hook: possible enhancement? Matthew Wozniski
2007-09-05 17:14 ` Bart Schaefer
2007-09-05 19:05   ` Peter Stephenson
2007-09-05 21:11     ` Matthew Wozniski
2007-09-08 17:20     ` Bart Schaefer
2007-09-05 19:32 ` Stephane Chazelas
2007-09-02 15:43 fg jobs info Atom Smasher
2007-09-02 17:59 ` Bart Schaefer
2007-09-03  7:38   ` Stephane Chazelas
2007-09-03 15:58     ` Bart Schaefer
2007-09-03 16:31   ` Matthew Wozniski
2007-09-04 11:16   ` Atom Smasher
2007-09-04 15:31     ` Bart Schaefer
2007-09-04 20:38       ` Peter Stephenson
2007-09-04 20:45       ` Peter Stephenson
2007-09-05  9:02       ` Atom Smasher
2007-09-05  9:28         ` Peter Stephenson
2007-09-05 11:21           ` Miek Gieben
2007-09-05 11:34             ` Matthew Wozniski
2007-09-05 11:36               ` Miek Gieben
2007-09-05 11:34             ` Atom Smasher
2007-09-05 11:40             ` Frank Terbeck
2007-09-05 12:18               ` Miek Gieben
2007-09-05 15:30           ` Bart Schaefer
2007-09-05 15:55             ` Peter Stephenson
2006-10-06 15:07 Move command line options to start of line Peter Stephenson
2006-10-07  2:55 ` Bart Schaefer
2006-10-07  6:20   ` Andrey Borzenkov
2006-10-07 12:02   ` Peter Stephenson
2006-10-07 12:39     ` Bart Schaefer
2006-10-07 17:21       ` Dan Nelson
2006-10-07 17:36       ` Peter Stephenson
2006-09-04  8:43 Solved, but now a new twist (was: Double Evaluation Question (not in FAQ)) Com MN PG P E B Consultant 3
2006-09-04 18:24 ` Bart Schaefer
2006-09-07 17:53   ` Peter Stephenson
     [not found] <schaefer@brasslantern.com>
2006-07-30  6:29 ` Rebinding a widget within a keymap Bart Schaefer
2006-07-30 17:18   ` Peter Stephenson
2006-07-30 17:46     ` Bart Schaefer

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=070401105359.ZM18385@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).