셸의 콜론(:)으로 인수 평가와 기본값 설정을 간결하게 할 수 있다.
셸의 콜론(:)은 어떤 동작도 수행하지 않는 널 명령으로, 매개변수 확장과 결합하여 필수 인수 검사와 기본값 설정이 가능하다. 예를 들어, <code>: "${1:?missing argument, aborting!}"</code>와 같은 방식으로 인수가 없을 때 오류를 발생시킬 수 있다. 이 방법을 통해 스크립트를 보다 간결하고 효율적으로 작성할 수 있다.
The shell colon (:) serves as a null command for argument evaluation and default value assignments.
The shell colon (:) acts as a null command that performs no action but can evaluate arguments. When combined with parameter expansion, it simplifies essential argument checks and default value assignments. For example, using <code>: "${1:?missing argument, aborting!}"</code> triggers an error if an argument is missing, making scripts cleaner and more efficient.