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

$var not expanded in ${x?$var}



$ zsh -c 'echo ${1?$USERNAME}'
zsh:1: 1: $USERNAME

No quote removal either:

$ zsh -c 'echo ${1?"x"}'
zsh:1: 1: "x"

Doc says:

> In any of the above expressions that test a variable and substitute an
> alternate WORD, note that you can use standard shell quoting in the WORD
> value to selectively override the splitting done by the SH_WORD_SPLIT
> option and the = flag, but not splitting by the s:STRING: flag.

POSIX:

> ${parameter:?[word]}
> Indicate Error if Null or Unset. If parameter is unset or
> null, the *expansion* of word (or a message indicating it is
> unset if word is omitted) shall be written to standard error
> and the shell exits with a non-zero exit status. Otherwise,
> the value of parameter shall be substituted. An interactive
> shell need not exit.

(also note that line number being printed twice)

-- 
Stephane




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