Files
tldr/pages.sv/common/[.md
Gabe Livengood 9d865abee1 test: Use POSIX-compliant example for equals comparison (#11728)
* [: 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.
2023-12-14 20:31:13 +05:30

555 B

[

Utvärdera villkor. Returnerar 0 om villkoret är sant, 1 om villkoret är falsk. Mer information: https://www.gnu.org/software/bash/manual/bash.html#index-test.

  • Testa om en given variabel är lika med en given sträng:

[ "{{$VARIABEL}}" = "{{/bin/zsh}}" ]

  • Testa om en given variabel är tom:

[ -z "{{$GIT_BRANCH}}" ]

  • Testa om filen existerar:

[ -f "{{väg/till/fil}}" ]

  • Testa om en katalog inte existerar:

[ ! -d "{{väg/till/katalog}}" ]

  • If-else uttryck:

[ {{villkor}} ] && {{echo "true"}} || {{echo "false"}}