Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Macros created via global aliases don't work



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