エイリアスとして隠されている場合は、シェル予約語を使用してください。

エイリアスとして隠されている場合は、シェル予約語を使用してください。

エイリアスが予約語を非表示にした場合、その予約語にどのようにアクセスできますか?

これは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).

おすすめ記事