Files
tldr/pages.pl/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

26 lines
645 B
Markdown

# [
> Sprawdza typy plików i porównuje wartości.
> Zwraca 0 gdy porównanie zwróciło wartość poprawną, 1 gdy fałszywą.
> Więcej informacji: <https://www.gnu.org/software/bash/manual/bash.html#index-test>.
- Sprawdź czy podana zmienna jest równa łańcuchowi znaków:
`[ "{{$ZMIENNA}}" = "{{/bin/zsh}}" ]`
- Sprawdź czy zmienna jest pusta:
`[ -z "{{$GIT_BRANCH}}" ]`
- Sprawdź czy plik istnieje:
`[ -f "{{ścieżka/do/pliku}}" ]`
- Sprawdź czy katalog nie istnieje:
`[ ! -d "{{ścieżka/do/katalogu}}" ]`
- Zapis jeśli porawne-jeśli fałszywe:
`[ {{warunek}} ] && {{echo "gdy poprawne"}} || {{echo "gdy fałszywe"}}`