zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: dominik.vogt@gmx.de, zsh-users@zsh.org
Subject: Re: Modifiers and parameter expansion?
Date: Fri, 2 Dec 2022 09:59:29 -0800	[thread overview]
Message-ID: <CAH+w=7ZSHeW2ppL29BOqSs=eFdi7uriiAThxae__KQjoOz=qTg@mail.gmail.com> (raw)
In-Reply-To: <Y4lnUsJbhruCjU1V@localhost>

On Thu, Dec 1, 2022 at 6:48 PM Dominik Vogt <dominik.vogt@gmx.de> 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.


  reply	other threads:[~2022-12-02 18:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 21:29 Dominik Vogt
2022-12-01 21:34 ` Eric Cook
2022-12-01 21:36   ` Bart Schaefer
2022-12-01 22:39     ` Dominik Vogt
2022-12-01 23:42       ` Bart Schaefer
2022-12-02  0:52         ` Dominik Vogt
2022-12-02  1:34           ` Bart Schaefer
2022-12-02  2:47             ` Dominik Vogt
2022-12-02 17:59               ` Bart Schaefer [this message]
2022-12-02  1:28         ` Dominik Vogt
2022-12-02  1:48           ` 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='CAH+w=7ZSHeW2ppL29BOqSs=eFdi7uriiAThxae__KQjoOz=qTg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=dominik.vogt@gmx.de \
    --cc=zsh-users@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).