Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Modifiers and parameter expansion?
- X-seq: zsh-users 28475
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: dominik.vogt@xxxxxx, zsh-users@xxxxxxx
- Subject: Re: Modifiers and parameter expansion?
- Date: Fri, 2 Dec 2022 09:59:29 -0800
- Archived-at: <https://zsh.org/users/28475>
- In-reply-to: <Y4lnUsJbhruCjU1V@localhost>
- List-id: <zsh-users.zsh.org>
- References: <Y4kcyW/acG5cPz+o@localhost> <1dcdd69c-ce29-921f-f0f0-6862f68b62a6@gmx.com> <CAH+w=7amodhidc8i1MqPWkqhYv2PkN56WmZQ8e-g-GU6p3F6GA@mail.gmail.com> <Y4ktCdAPhIVR7bGk@localhost> <CAH+w=7b5rQNkfQcRb1zVDbD5CMn-8F67pGS9JvshqyRiFF6nXw@mail.gmail.com> <Y4lMMptVvkj62FF3@localhost> <CAH+w=7ZFbSnx74mr=ZjRzfUQP0k6i9Xime3E1sCytaios-HqDA@mail.gmail.com> <Y4lnUsJbhruCjU1V@localhost>
On Thu, Dec 1, 2022 at 6:48 PM Dominik Vogt <dominik.vogt@xxxxxx> wrote:
>
> On Thu, Dec 01, 2022 at 05:34:18PM -0800, Bart Schaefer wrote:
> > Not sure where you came up with that.
>
> [Implicit: the braces can be omitted, unless]
OK ... but that didn't come from the context in the doc, which uses
the form with braces ${NAME} as the base case.
> (The implicit statement is the _only_ "mention" of the brace-less
> form at all.)
"with or without braces" is explicitly in the last sentence? But
again the manual is largely written from the viewpoint of someone who
knows how shells work and therefore is familiar with the $NAME case
and needs to be told the way zsh might diverge from that.
> > ${=X}
> > ${~X}
> > ${#X}
> > ${+X}
>
> These work without braces even if KSH_ARRAYS is set.
Hmm, I would say that's a bug, then, in "emulate sh" if not in
KSH_ARRAYS. $#X should be interpreted as ${#}X (and is, with "emulate
sh", even though there's no specific setopt controlling it). Bash
doesn't even attempt to expand the other three, they're treated as not
being substitutions at all; you get an error only on e.g. ${+X}.
I suppose allowing them to work without braces is an extension in the
same way that supporting them with braces is an extension.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author