zsh-workers
 help / color / mirror / code / Atom feed
From: Martijn Dekker <martijn@inlv.org>
To: zsh-workers@zsh.org
Subject: Alias expansion inconsistency in $(command substitutions) with IGNORE_CLOSE_BRACES
Date: Sun, 16 Apr 2017 17:07:09 +0100	[thread overview]
Message-ID: <131b162a-b1f8-998c-e5ca-6a161dfef16f@inlv.org> (raw)

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.


             reply	other threads:[~2017-04-16 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-16 16:07 Martijn Dekker [this message]
2017-04-21 19:58 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=131b162a-b1f8-998c-e5ca-6a161dfef16f@inlv.org \
    --to=martijn@inlv.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).