"리눅스 set -e"의 두 판 사이의 차이

잔글 (cat b.sh -> cat a.sh)
 
(사용자 2명의 중간 판 2개는 보이지 않습니다)
5번째 줄: 5번째 줄:


==실습==
==실습==
<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:~# cat a.sh
root@zetawiki:~# cat a.sh
echo hello
echo hello
cat asdfasdfasdf
cat asdfasdfasdf
echo world
echo world
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:~# sh a.sh
root@zetawiki:~# sh a.sh
hello
hello
cat: asdfasdfasdf: No such file or directory
cat: asdfasdfasdf: No such file or directory
world
world
</source>
</syntaxhighlight>
:→ 오류가 발생해도 스크립트를 끝까지 수행함
:→ 오류가 발생해도 스크립트를 끝까지 수행함


<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:~# cat b.sh
root@zetawiki:~# cat a.sh
set -e
set -e
echo hello
echo hello
cat asdfasdfasdf
cat asdfasdfasdf
echo world
echo world
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:~# sh a.sh
root@zetawiki:~# sh a.sh
hello
hello
cat: asdfasdfasdf: No such file or directory
cat: asdfasdfasdf: No such file or directory
</source>
</syntaxhighlight>
:→ 오류가 발생하면 스크립트를 즉시 종료시킴
:→ 오류가 발생하면 스크립트를 즉시 종료시킴


==같이 보기==
==같이 보기==
* [[리눅스 set]]
* [[리눅스 set -x]]
* [[리눅스 set -x]]
* [[리눅스 set]]
* [[리눅스 set -euxo pipefail ]]


[[분류: 리눅스 set]]
[[분류: 리눅스 set]]

2022년 5월 9일 (월) 10:01 기준 최신판

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 }}