エイリアスが予約語を非表示にした場合、その予約語にどのようにアクセスできますか?
これはif
うまくいきます:
% if : ; then echo true; fi
true
エイリアスの後ろif
:
% alias if=date
% if : ; then echo true; fi
zsh: parse error near `then'
接頭辞builtin
または\
役に立たない:
% builtin if : ; then echo true; fi
zsh: parse error near `then'
% \if : ; then echo true; fi
zsh: parse error near `then'
エイリアスのために隠された病理学的な場合、予約語にアクセスする方法は?
ベストアンサー1
ヒリーの答え私に指摘してください。POSIXシェルコマンド言語セクション2.3.1これは次のように言います。
ただし、正しい構文コンテキストの予約語は、別名置換候補にしてはいけません。
{ba,z}sh
デフォルトの動作が上記の内容に従わないことを確認しました。
私は尋ねたzsh-workers
オプションに移動しますPOSIX_ALIASES
。マニュアルページ説明する:
POSIX_ALIASES <K> <S> When this option is set, reserved words are not candidates for alias expansion: it is still possible to declare any of them as an alias, but the alias will never be expanded. Reserved words are described in the section RESERVED WORDS in zshmisc(1).