Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Macros created via global aliases don't work
- X-seq: zsh-workers 44653
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Aryn Starr <whereislelouch@xxxxxxxxxx>
- Subject: Re: Macros created via global aliases don't work
- Date: Mon, 12 Aug 2019 17:31:13 -0700
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9BiwaFyq8EWtk7EVWTua0rmIN/w7GoT4WpTHvFw6be4=; b=zhGIzYoY2ByeOSWwcgXLDM9MFbBi62Z612DFWqbO0Z9kcYtwSh29F+vbnEtXldOWMl p2bG9H9HZj7CYjsCvIXZ312V92wcfh99qGdvX4iGr/icsyxIbzhbHZ0m5zVRsxQsgPfK 40bDp0T7TYhdUOvAD+gx0IYiEcqKWKeeVM6xVy7O5S0aMPebFwh6LcBnF4JOPDLTrJEU jH0KZUkN+HZubcknFlHfNnUS+KxpcNsvRnB9Oz49bAp+PbiGuBhAtdzjsqY0kBIyj90m ge6eytCjmy9aJXXrhAnXKNQNUFr6AJbFKGHofkkR/ZfNxqN2NHauh9byr3PYTSOG5HK1 AAnw==
- In-reply-to: <5E74A664-7781-4FDC-B640-FDFDCDB2A104@icloud.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <5E74A664-7781-4FDC-B640-FDFDCDB2A104@icloud.com>
On Mon, Aug 12, 2019 at 1:55 AM Aryn Starr <whereislelouch@xxxxxxxxxx> wrote:
>
> alias -g MAGIC=')"'
> alias mdoc='eval "$(m_doc "$*" "$0" '
>
> mdoc Usage: Some documentation here. MAGIC
You've created an ambiguous "sentence". Aliases are not really
macros; they are both expanded and parsed left-to-right, not fully
expanded before parsing begins. The ambiguity is that because you've
hidden the closing paren from the parser, it follows through the
depth-first interpretation rather than the breadth-first.
First mdoc expands, and then that expansion is parsed, so now the
parser is now working inside the command substitution, and when MAGIC
expands the shell sees it as part of the m_doc command rather than as
part of the mdoc command, if you see what I mean.
I think you can unambiguously get what you're after by using
alias mdoc='m_doc '
alias -g MAGIC='| { eval "$(read -d "" -r -E)" }'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author