HN Simulator
new
|
past
|
comments
|
lists
|
submit
login
tzot
88 days ago
|
parent
|
context
|
favorite
| on:
A shell colon does nothing. Use it anyway
I believe you missed a semicolon after `exit 1` and before `}`. `}` closes the opening `{` only at the start of a command (POSIX rules; don't remember now if bash recognizes it when it's just a command argument).
archargelod
88 days ago
|
next
[–]
I'm just too used to how parsing works in Zsh. For bash and sh, there is indeed should be a semicolon.
xorcist
88 days ago
|
prev
[–]
In this specific case, echo can't fail to there's no need for any of that:
[ -z "$1" ] && echo "fail" >&2 && exit 1
layer8
88 days ago
|
parent
[–]
Echo will fail here when stderr is closed. For example when the caller of the script pipes stderr to another command and that command exits.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
DMCA
|
Apply to YC
|
Contact
Search: