Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: unexpected clearing of parameter flags with ::=
- X-seq: zsh-workers 54673
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: unexpected clearing of parameter flags with ::=
- Date: Thu, 4 Jun 2026 08:09:10 +0200
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=clPn2UGLdhu1kwhhPm7dNLeFxNDEdRUwkFlTFt7KrLw=; fh=SbTlPuNNxBzTkRlwWtqw/TXBY0HvGvtE97RpPp3sJPM=; b=jgzWylpPnncZQUEvblQ3pJajhbPxG9ki/d3xwSgI3oDqnpCvavYuSTqEkefcm2Fq8I xSSdc4InsIOea/zEDoNOr6UL89JuNFPeuryUTQWO1j7YllPDkri+jEdrfo+3/sWdjR74 Yxj8DH0KcweeDRNpTD63fMUhmuJ/yIyGw8uDNAyNaMKiPA8N21zY0ihvwYf8xUA6joQ+ h4xaZbh9xJaBVAg4Wsx1RgffXq29PTWBj16/TxTxvycCETJg9ygU/nAJr5nFK+lXvCMk nDqLuM+Y1AiB6RKQdFfam9oZ70MLYB2uoqBfkGYsdHVjVCR6h96tujVSFLB+aIoj0RtH gLhQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1780553363; cv=none; d=google.com; s=arc-20240605; b=CuZqAI5mQwGHmw8lRkpYQu2wdwT1hc/ljuPlnqF2p9/vDg3/ey2aVodHTaItrorGMi fldJlAUB1T++tFJqg8CpOuqL8fe+6hqsPORM5mC9pH0mvG5NWSuKFsCw3P3ehX5weB4n P90dM75bDhI5ycMNJp6cTW58i/ZQXJSk3J0/ga2nkUvNtZ+7RA0DFILi1m/PZVDz58XR p5htT2A53+Z7N+abfNLuVjUvvPhHB6a5m8ZgNRQnMAk/vY4hAwaJl8FJzMzg4u0CPiXm F5mACkX18M4DSpQfn3Ro6Qw4VlBlFcPfiDaizvMviTpYPbhhW9VEC25pwr3iDy0msU0k 6L1w==
- Archived-at: <https://zsh.org/workers/54673>
- In-reply-to: <CAHYJk3TU-x6dXJFy1EzkyoS93gS3hS1ZMMCjVQB_-82h6fSLZQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAHYJk3TU-x6dXJFy1EzkyoS93gS3hS1ZMMCjVQB_-82h6fSLZQ@mail.gmail.com>
On Mon, May 2, 2022 at 9:46 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> % typeset -Z3 i
> % echo ${i=5}
> 005
> % echo ${i:=15}
> 005
> % echo ${i::=15}
> 15
At this point,
% echo ${i}
015
>
> 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}
This actually echoes three spaces (not included in my original mail apparently):
% echo _${i:=25}_
_ _
> but this does set it:
> % unset i
> % typeset i
> % echo ${i:=25}
> 25
and again, echo ${i} here shows 025 as expected.
> 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?
The -Z3 implicit value does take effect, but because there is no
digit, it is padded with spaces instead of zeroes, which I apparently
overlooked.
So to clarify my original confusion, := does nothing on a parameter
declared with typeset -Z3 because it expands to be padded before
checking if it's "empty", despite actually being unset, and ::= shows
the assigned value ignoring the parameter flags (but the flags aren't
actually cleared, they just aren't used for the particular expansion
that used ::=).
Would we consider either or both of these to be bugs?
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author