소스 검색

if: add if conditions with examples (#3206)

Alexander Berezovsky 5 년 전
부모
커밋
89a3e79198
1개의 변경된 파일16개의 추가작업 그리고 0개의 파일을 삭제
  1. 16 0
      pages/common/if.md

+ 16 - 0
pages/common/if.md

@@ -9,3 +9,19 @@
 - Full if syntax:
 
 `if {{condition}}; then echo "true"; else echo "false"; fi`
+
+- List available if conditions:
+
+`help test`
+
+- Test if a given variable is empty:
+
+`if [[ -z $GIT_BRANCH ]]; then echo "true"; else echo "false"; fi`
+
+- Test if a file exists:
+
+`if [[ -e {{filename}} ]]; then echo "true"; else echo "false"; fi`
+
+- If directory not exists:
+
+`if [[ ! -d {{path/to/directory}} ]]; then echo "true"; else echo "false"; fi`