mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-23 14:02:08 +02:00

* [: use posix-compliant example for equals comparison the previous example worked fine for bash, but some other shells (zsh, in my case) will not work when using "==" for comparison. the posix spec only requires "=", so I think it makes a little more sense to use that in the example. * test: use posix-compliant example for equals comparison the previous example worked fine for bash, but some other shells (zsh, in my case) will not work when using "==" for comparison. the posix spec only requires "=", so I think it makes a little more sense to use that in the example.
719 B
719 B
test
条件を評価します。 条件が真と評価された場合は 0 を、偽と評価された場合は 1 を返します。 詳しくはこちら: https://www.gnu.org/software/coreutils/test
- 与えられた変数が与えられた文字列と等しいかどうかをテスト:
test "{{$変数名}}" = "{{/bin/zsh}}"
- 与えられた変数が空であるかどうかをテスト:
test -z "{{$変数名}}"
- ファイルが存在するかどうかをテスト:
test -f "{{ファイルへのパス}}"
- ディレクトリが存在しないかどうかをテスト:
test ! -d "{{ディレクトリへのパス}}"
- if-else 文:
test {{条件}} && {{echo "真"}} || {{echo "偽"}}