zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: unexpected clearing of parameter flags with ::=
Date: Mon, 2 May 2022 09:46:15 +0200	[thread overview]
Message-ID: <CAHYJk3TU-x6dXJFy1EzkyoS93gS3hS1ZMMCjVQB_-82h6fSLZQ@mail.gmail.com> (raw)

% typeset -Z3 i
% echo ${i=5}
005
% echo ${i:=15}
005
% echo ${i::=15}
15

The manpage says
 ${name::=word}
  In the first form, if name is unset then set it to word; in the second
  form, if name is unset or null then set it to word; and in  the  third
  form,  unconditionally  set  name to word.  In all forms, the value of
  the parameter is then substituted.

which to me doesn't imply that the parameter is reset first,
especially since it isn't reset for the first form. I'm a little
confused as to why this doesn't assign the value either:

% unset i
% typeset -Z3 i
% echo ${i:=25}

but this does set it:
% unset i
% typeset i
% echo ${i:=25}
25

I thought maybe -Z3 causes the implicit value to be 000 but it is
printed as empty, so shouldn't it fulfil the "unset or null" condition
despite the -Z flag being active?

-- 
Mikael Magnusson


                 reply	other threads:[~2022-05-02  7:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAHYJk3TU-x6dXJFy1EzkyoS93gS3hS1ZMMCjVQB_-82h6fSLZQ@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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).