`test`と`[` - 異なるバイナリ、違いはありますか?

`test`と`[` - 異なるバイナリ、違いはありますか?

test他の質問への答えからとは異なる[バイナリであることがわかりましたが、[マンページではtestエンディングが必要なこと以外に何か]他の点はありますか?そうでなければ、なぜシンボリックリンクではなく別々のバイナリですか? (またbash内蔵されており、bash違いはありません。)

ベストアンサー1

これソースコード--helpオプションの処理方法の違いを説明してください。

  /* Recognize --help or --version, but only when invoked in the
     "[" form, when the last argument is not "]".  Use direct
     parsing, rather than parse_long_options, to avoid accepting
     abbreviations.  POSIX allows "[ --help" and "[ --version" to
     have the usual GNU behavior, but it requires "test --help"
     and "test --version" to exit silently with status 0.  */

デモ

$ /usr/bin/test --help
$
$ /usr/bin/[ --help
Usage: test EXPRESSION
  or:  test
  or:  [ EXPRESSION ]
  or:  [ ]
  or:  [ OPTION
Exit with the status determined by EXPRESSION.
[...]

bash内蔵バージョンでは、あなたが言ったように最後になければならない点だけが[異なります。]

おすすめ記事