# 안전한 쉘 스크립트 작성하기

> Clean Markdown view of GeekNews topic #1434. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=1434](https://news.hada.io/topic?id=1434)
- GeekNews Markdown: [https://news.hada.io/topic/1434.md](https://news.hada.io/topic/1434.md)
- Type: news
- Author: [xguru](https://news.hada.io/@xguru)
- Published: 2020-02-03T12:38:29+09:00
- Updated: 2020-02-03T12:38:29+09:00
- Original source: [sipb.mit.edu](https://sipb.mit.edu/doc/safe-shell/)
- Points: 7
- Comments: 0

## Topic Body

- 가능하면 쉘 쓰지 말고 파이썬 같은걸로 짜세요

- 꼭 써야 한다면 set -euf -o pipefail 을 추천

= -e : 한줄이라도 실패하면 중단

= -u : unset변수는 에러로 취급하고 바로 종료

= -f : 파일이름 확장(globbing) 제한

= -o pipefail : 파이프 중간에 에러나면 에러 출력하고 -e 로 바로 종료

- 인용부호(따옴표) 많이쓰기 : 대부분의 경우 $*, $@ 가 아니라 "$@"

- "-"로 시작하는 파일명,인자 조심하기

- ShellCheck로 버그 찾기

## Comments



_No public comments on this page._
