====== Bash Exit Code ====== * 바로 직전 프로그램의 Exit code를 판단하여 분기하려면 ''$?'' 환경변수 사용. [[http://steve-parker.org/sh/exitcodes.shtml|Unix / Linux Bourne / Bash Shell Scripting Tutorial]] 참조. # 프로그램 실행. if [ "$?" -ne "0" ]; then echo "Sorry, cannot find user ${1} in /etc/passwd" exit 1 fi * [[http://stackoverflow.com/questions/1221833/bash-pipe-output-and-capture-exit-status|tee 혹은 기타 프로그램으로 파이프를 통과 시켰을 때 각 파이프 프로그램들의 Exit Code]] # PIPESTATUS에 배열로 들어가며, 최초 명령의 Exit code는 PIPESTATUS[0]에 들어간다. | tee out.txt test ${PIPESTATUS[0]} -eq 0