리눅스 set -e

LSH4290 (토론 | 기여)님의 2022년 5월 9일 (월) 10:01 판 (cat b.sh -> cat a.sh)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

set -e
  • 오류가 발생하면 중단시키는 설정
  • Exit immediately if a command exits with a non-zero status.

2 실습[ | ]

root@zetawiki:~# cat a.sh
echo hello
cat asdfasdfasdf
echo world
root@zetawiki:~# sh a.sh
hello
cat: asdfasdfasdf: No such file or directory
world
→ 오류가 발생해도 스크립트를 끝까지 수행함
root@zetawiki:~# cat a.sh
set -e
echo hello
cat asdfasdfasdf
echo world
root@zetawiki:~# sh a.sh
hello
cat: asdfasdfasdf: No such file or directory
→ 오류가 발생하면 스크립트를 즉시 종료시킴

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}