Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Modifiers and parameter expansion?



On Thu, Dec 1, 2022 at 4:52 PM Dominik Vogt <dominik.vogt@xxxxxx> wrote:
>
> > >        7. Modifiers
>
> Okay.  Why are "%" "%%" "#" "##" "/" "//" refered to in this
> section?

Because they happen to be interpreted at the same "step" as modifiers,
and the documentation grew organically?

> > In the Parameter Expansion section
> >
> > ${NAME}
>
> The braces are required unless(1) they are not(2) required
> unless(3) some option is not(4) present.  Quadruple negative.

Not sure where you came up with that.  The braces are required when
(A) or when (B) or when (C), except (D) when not (C).
(A) followed by something may be part of an identifier
(B) complicated forms
(C) KSH_ARRAYS
(D) colons after or other tokens before

> All I understand is that it's trial and error to figure out
> whether braces are required.

Nonsense.

>   $ unsetopt KSH_ARRAYS
>   $ echo ^a =ls
>   $ echo ~a

No, that's completely irrelevant.  The BRACES aren't required, but the
$ IS.  The above is not parameter expansion.

NO_KSH_ARRAYS allows
$X[2]
$X:h
$^X
$=X
$~X
$#X
$+X

KSH_ARRAYS requires
${X[2]}
${X:h}
${^X}
${=X}
${~X}
${#X}
${+X}

> This section could be split in two, to improve readability:

Possibly, but that affects several of the following descriptions as well.




Messages sorted by: Reverse Date, Date, Thread, Author