Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Macros created via global aliases don't work
- X-seq: zsh-workers 44651
- From: Aryn Starr <whereislelouch@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Macros created via global aliases don't work
- Date: Mon, 12 Aug 2019 13:24:36 +0430
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1565600081; bh=BDGYb5H9NZO2/C/GqlmXl7ruZlrdKBQg4all9Dpm7kA=; h=From:Content-Type:Subject:Message-Id:Date:To; b=EPCxB4FL5Q+wQxjrUNJh/RrV8yFG5J82Hd/dJREbYkqAK3yh9mv72KdOEger1Vk2j 2DkVWpfiaTE+bV3JBXZYIvtO+qi/NEOyKHU4v5reSHzyqKm545ZxxLQ/ABQ16MdTWi bH59imjSMtkl8n9ow40T8qCmkoHBDhGwi6EaMqCGU8Ul6Gdg9TFJH7gufWPictZ8h1 hWRlx7wBaBppBL4hhbp+qkfYvfq9t7GTnW1ftW/gdX4MFyH33lIv2WE53CMGzyhZDC nlOBURgf0JYnyK2DW6qEXV0irwuw516tf8Ndwri9pD9UgJwHpXNFq0LsXlTYZ7KiUH auEmrenRRwmOg==
- 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
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?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author