mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-29 23:24:55 +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.
635 B
635 B
test
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/coreutils/test.
- Sprawdź czy podana zmienna jest równa łańcuchowi znaków:
test "{{$ZMIENNA}}" = "{{/bin/zsh}}"
- Sprawdź czy zmienna jest pusta:
test -z "{{$GIT_BRANCH}}"
- Sprawdź czy plik istnieje:
test -f "{{ścieżka/do/pliku}}"
- Sprawdź czy katalog nie istnieje:
test ! -d "{{ścieżka/do/katalogu}}"
- Zapis jeśli porawne-jeśli fałszywe:
test {{warunek}} && {{echo "gdy poprawne"}} || {{echo "gdy fałszywe"}}