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

Alias expansion inconsistency in $(command substitutions) with IGNORE_CLOSE_BRACES



If either the IGNORE_CLOSE_BRACES or IGNORE_BRACES option is active,
there is an inconsistency in alias expansion within command
substitutions, specifically those of the form $(command).

Given:

% set -o ignoreclosebraces
% alias OPEN='{' CLOSE='};'

These work fine:

% { OPEN echo hi; CLOSE }
hi
% var=`{ OPEN echo hi; CLOSE }` && echo "$var"
hi

But this does not:

% var=$({ OPEN echo hi; CLOSE }) && echo "$var"
zsh: parse error near `)'
zsh: parse error near `var=$({ OPEN echo hi...'

This inconsistency seems to have been introduced around zsh 5.2; it's
not present in zsh 5.1.1 and earlier.

Thanks,

- M.

In case anyone wonders about an actual use case for aliases like these,
it's the var/setlocal module of modernish, my cross platform POSIX shell
library:
https://github.com/modernish/modernish#user-content-use-varsetlocal
This basically brings the functionality of zsh anonymous functions to
plain POSIX shells. Of course this would be redundant on scripts written
for zsh, but it would be nice if cross-shell scripts run consistently.



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