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

Re: Modifiers and parameter expansion?



More inaccuracies in the man page:

On Thu, Dec 01, 2022 at 03:42:27PM -0800, Bart Schaefer wrote:
> ${NAME}
>      The value, if any, of the parameter NAME is substituted.  The
>      braces are required if the expansion is to be followed by a letter,
>      digit, or underscore that is not to be interpreted as part of NAME.

Actually that is only true for "normal" parameters.  Neither of the
special parameters except "_" treats the following characters as
part of the name.

  $ A=abc
  $ echo $?A $@A $*A $-A $$A $!A $#A
  0A A A 0569EKNXZghikmsA 5775A 0A 3

>      In addition, more complicated forms of substitution usually require
>      the braces to be present; exceptions, which only apply if the
>      option KSH_ARRAYS is not set, are a single subscript or any colon
>      modifiers appearing after the name

This is fishy.  With braces, unknown modifiers are rejected,
without braces they are used as literal text:

  $ unsetopt KSH_ARRAYS
  $ X=abc; echo $X:Z
  abc:Z
  $ echo ${X:Z}
  zsh: unrecognized modifier `Z'

Should at least be documented.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt




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