Awesome
A shell script template suitable for most software developers
This repository contains:
hello
: take this script with you and modify it at leisure.hello-teacher
: is a commented version ofhello
for learning rather than for production code.
Short advice for successful shell scripting:
- Treat it like any other programming language.
- Require a modern version of bash (>= 4.3).
- Use
"$thing"
, not$thing
unless you want to split the string. - Learn the scoping rules and how to use functions.
- Learn how to use arrays.
- Use ShellCheck. It's helpful for learning, not just for going after production code.
Common conventions that minimize annoyances:
- An executable file should have no extension because it's a command name that should be
meaningful to the user. It's
hello
, nothello.sh
. The implementation language is irrelevant to the caller of the command. - Environment variables should use all-caps e.g.
"$USER"
. Ordinary shell variables should use lowercase e.g."$name"
.