TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Safe-r Bash Scripting

5 pointsby kyleburtonalmost 16 years ago

1 comment

vlisivkaalmost 16 years ago
Use "set -u" to treat unset variables as an error when substituting. Use "||" operator to handle errors. My pattern:<p>an_command || { error "Cannot execute an_command. Exit code: $?." return 1 }<p>Always wrap variables with double quotes, unless you really need to parse variable value by bash. Use arrays, when you need to pass multiple arguments. And so on.