사용자 도구

사이트 도구


linux:bash

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
linux:bash [2020/02/12 09:55]
kwon37xi [변수들]
linux:bash [2020/09/05 14:34]
kwon37xi [set -e/+e]
줄 197: 줄 197:
 echo "${MY_ENV}" > myfile.txt echo "${MY_ENV}" > myfile.txt
 </code> </code>
 +
 +
 +===== Safe Shell Script =====
 +  * [[https://sipb.mit.edu/doc/safe-shell/|Writing Safe Shell Scripts]]
 +  * [[https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/|Safer bash scripts with 'set -euxo pipefail' · vaneyckt.io]]
 +
 +<code sh>
 +set -euf -o pipefail
 +</code>
 +
 +==== set -e/+e ====
 +  * ''set -e'' : 오류 발생시 즉시 종료. 이것보다는 ''trap'' 사용을 권장함. [[http://mywiki.wooledge.org/BashFAQ/105|BashFAQ/105 -Why doesn't set -e (or set -o errexit, or trap ERR) do what I expected?]]
 +  * ''set +e'' : 기본값. 오류 발생해도 무시하고 스크립트 진행.
  
 ===== 참조 ===== ===== 참조 =====
줄 213: 줄 226:
   * [[https://zwischenzugs.com/2018/01/06/ten-things-i-wish-id-known-about-bash/|Ten Things I Wish I’d Known About bash – zwischenzugs]]   * [[https://zwischenzugs.com/2018/01/06/ten-things-i-wish-id-known-about-bash/|Ten Things I Wish I’d Known About bash – zwischenzugs]]
   * [[https://devhints.io/bash.html|Bash scripting cheatsheet]]   * [[https://devhints.io/bash.html|Bash scripting cheatsheet]]
- +  * [[https://github.com/Idnan/bash-guide|GitHub - Idnan/bash-guide: A guide to learn bash]] 
 +  * [[http://mywiki.wooledge.org/BashFAQ#BashFAQ.2F035.How_can_I_handle_command-line_options_and_arguments_in_my_script_easily.3F|BashFAQ - Greg's Wiki]]
linux/bash.txt · 마지막으로 수정됨: 2024/02/07 08:41 저자 kwon37xi