From: Aryn Starr <whereislelouch@icloud.com>
To: zsh-workers@zsh.org
Subject: Macros created via global aliases don't work
Date: Mon, 12 Aug 2019 13:24:36 +0430 [thread overview]
Message-ID: <5E74A664-7781-4FDC-B640-FDFDCDB2A104@icloud.com> (raw)
Hi! I am trying to create a macro in zsh using global aliases:
```
alias -g MAGIC=')"'
function m_doc() {
print -r -- "! { [[ ${(q+)1} == '-h' ]] || [[ ${(q+)1} == '--help' ]] } || {
print -r -- \"Help for $2:
$@[3,-1]\” ; return 0 }"
}
alias mdoc='eval "$(m_doc "$*" "$0" '
## Testing it
mdoc_test() {
mdoc Usage: Some documentation here. MAGIC
echo “You shouldn’t see this if using the help flags"
}
## Running this:
#$ mdoc_test -h
#mdoc_test:1: parse error near `)'
#mdoc_test:1: parse error in command substitution
mdoc_test2() {
eval "$(m_doc "$*" "$0" Usage: Some documentation here.)"
ec "$*"
}
## Running this:
#$ mdoc_test2 -h 1
#Help for mdoc_test2:
#Usage: Some documentation here.
mdoc_test3() {
eval "$(m_doc "$*" "$0" Usage: Some documentation here. MAGIC
ec "$*"
}
## Running this:
#$ mdoc_test3 -h
#mdoc_test3:1: parse error near `)'
#mdoc_test3:1: parse error in command substitution
```
It seems to me that this is a bug?
next reply other threads:[~2019-08-12 8:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 8:54 Aryn Starr [this message]
2019-08-13 0:31 ` Bart Schaefer
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=5E74A664-7781-4FDC-B640-FDFDCDB2A104@icloud.com \
--to=whereislelouch@icloud.com \
--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).