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

POSIX: reserved words should not expand into aliases



The [POSIX Shell Command Language section 2.3.1](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_03_01) says:

> However, reserved words in correct grammatical context shall not be candidates for alias substitution.

It seems that both `{ba,z}sh` have a bug here.

How do I access a reserved word if an alias is hiding it?

Here `if` works normally:

    % if : ; then echo true; fi
    true

After aliasing `if`:

    % alias if=date
    % if : ; then echo true; fi
    zsh: parse error near `then'

Prefixing with `builtin` or `\` doesn't help:

    % builtin if : ; then echo true; fi
    zsh: parse error near `then'
    % \if : ; then echo true; fi
    zsh: parse error near `then'

How do I access a reserved word in the pathological case that it hidden by an alias?


Prior art: https://unix.stackexchange.com/q/456408/143394



Messages sorted by: Reverse Date, Date, Thread, Author