3

I'm trying to get a literal } in the output of the ${parameter:?word} expansion in zsh.

In bash, it works as expected -- I can quote the } with a \:

% bash           
$ echo "${unset_var_name?Here is a close brace >>\}<<}" 
bash: unset_var_name: Here is a close brace >>}<<

But I can't work out how to do the same in zsh:

% zsh                                                                                           
% echo "${unset_var_name?Here is a close brace >>\}<<}" 
zsh: unset_var_name: Here is a close brace >>\}<<

Note that the \ appears literally above.

5

1 Answer 1

2

Yes, that, and the fact that $var2 is not expanded for instance in ${var1?$var2} was an unnecessary and unfortunate deviation from all other shells and from the POSIX specification of sh and was fixed in zsh in February 2023, so will be available in the next release whether that's 5.10 or 6.0.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .