zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: <zsh-users@sunsite.auc.dk>, Heinrich Go%tzger <goetzger@gmx.net>
Subject: Re: Problems with Parameter Expansion :=
Date: Wed, 14 Feb 2001 12:56:08 -0800	[thread overview]
Message-ID: <010214125608.ZM1498@candle.brasslantern.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0102142100460.1246-100000@exploding.fh-konstanz.de>

On Feb 14,  9:28pm, Heinrich Go%tzger wrote:
> Subject: Problems with Parameter Expansion :=
> 
> if [ ${NAME1:=""} = "true" ]
> then
>         echo "true"
> fi

> $ . script.sh
> odin
> script.sh:6: parse error: condition expected: =
> 
> Why does it not expand NAME1 to "" ?

We've actually just been having a discussion about this on zsh-workers.

${NAME1:=""} sets NAME1 to the empty string and then substitutes the
resulting value of $NAME1, which is exactly what the zsh docs say it
will do.

Bourne shell and ksh, however, set NAME1 to the empty string and then
substitute the empty string, which is not the same thing.

The most straightforward thing that will work in all of sh/ksh/zsh is

	if [ "${NAME1:=''}" = "true" ]

so that the entire ${...} is quoted.


  reply	other threads:[~2001-02-14 20:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-14 20:28 Heinrich Götzger
2001-02-14 20:56 ` Bart Schaefer [this message]
2001-02-14 22:11 ` Thomas Köhler

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=010214125608.ZM1498@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=goetzger@gmx.net \
    --cc=zsh-users@sunsite.auc.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).