From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id fbe8ecca for ; Tue, 13 Aug 2019 00:32:12 +0000 (UTC) Received: (qmail 12977 invoked by alias); 13 Aug 2019 00:32:02 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44653 Received: (qmail 7151 invoked by uid 1010); 13 Aug 2019 00:32:02 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf1-f54.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25538. spamassassin: 3.4.2. Clear:RC:0(209.85.167.54):SA:0(-1.9/5.0):. Processed in 1.907157 secs); 13 Aug 2019 00:32:02 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.167.54 as permitted sender) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9BiwaFyq8EWtk7EVWTua0rmIN/w7GoT4WpTHvFw6be4=; b=AXFbfByxzMy9NSSR9Mrr/dsgcq0oEzkpC8/IYALtdh2Yr3poM2oZbvQe0RwIh0C2C/ RmEESM5S0J4U64uxmUhx1v96SyuxN6BIX09i+aAqUQj2sbEmpwm2WcVTRCvvBuj50wYi 3kp6i9saESoXPYpYxbE7mBxDnMiazmOtTiMA0YLst/tbvPl1eO4B/zPh8wSPnQXEFVmM fc1QWheKIqtP2ON33aEtGeZQ6FXK8euf+vNPD/XDyJtGO/gwyaqPDhwcJDM1zS+PLbml MPlVegQ+FVWPo7w+mMfqVeBLdz5e/WmSKIECYsjx2lRJ76uMFQQw+udYsOx01IE5f3oG Dp7g== X-Gm-Message-State: APjAAAUTa1NO3io7+0dtOn9/xSd0xJljretr7n6ftURwN1A17brIKzyG zjn/gbYTTeR/f+uiskTY6/UUaQrzi1iObvMRl3f3zw== X-Google-Smtp-Source: APXvYqzOH7dQe5uORQckIHGYPZNIRL8AN8Gs9Qe90PgXZQljWNlpf5i/+RdVC5597+629B0KKqhvT8xWhEGBj1HO4ME= X-Received: by 2002:a19:7006:: with SMTP id h6mr21109496lfc.5.1565656285200; Mon, 12 Aug 2019 17:31:25 -0700 (PDT) MIME-Version: 1.0 References: <5E74A664-7781-4FDC-B640-FDFDCDB2A104@icloud.com> In-Reply-To: <5E74A664-7781-4FDC-B640-FDFDCDB2A104@icloud.com> From: Bart Schaefer Date: Mon, 12 Aug 2019 17:31:13 -0700 Message-ID: Subject: Re: Macros created via global aliases don't work To: Aryn Starr Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" On Mon, Aug 12, 2019 at 1:55 AM Aryn Starr 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)" }'