Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
$var not expanded in ${x?$var}
- X-seq: zsh-workers 51302
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: $var not expanded in ${x?$var}
- Date: Fri, 13 Jan 2023 08:02:46 +0000
- Archived-at: <https://zsh.org/workers/51302>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
$ 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