zsh-workers
 help / color / mirror / code / Atom feed
* Macros created via global aliases don't work
@ 2019-08-12  8:54 Aryn Starr
  2019-08-13  0:31 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Aryn Starr @ 2019-08-12  8:54 UTC (permalink / raw)
  To: zsh-workers

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?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-13  0:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12  8:54 Macros created via global aliases don't work Aryn Starr
2019-08-13  0:31 ` Bart Schaefer

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).