Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mjambon/reasonable-shell-script
Because shell scripts don't have to be terrible
https://github.com/mjambon/reasonable-shell-script
Last synced: 20 days ago
JSON representation
Because shell scripts don't have to be terrible
- Host: GitHub
- URL: https://github.com/mjambon/reasonable-shell-script
- Owner: mjambon
- License: unlicense
- Created: 2020-05-24T22:46:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-25T22:08:41.000Z (over 3 years ago)
- Last Synced: 2024-10-04T11:57:51.478Z (about 1 month ago)
- Language: Shell
- Size: 19.5 KB
- Stars: 62
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - reasonable-shell-script
README
# A shell script template suitable for most software developers
This repository contains:
* [`hello`](hello): take this script with you and modify it at leisure.
* [`hello-teacher`](hello-teacher): is a commented version of `hello`
for learning rather than for production code.Short advice for successful shell scripting:
1. Treat it like any other programming language.
2. Require a modern version of bash (>= 4.3).
3. Use `"$thing"`, not `$thing` unless you want to split the string.
4. Learn the [scoping rules](https://twitter.com/mjambon/status/1264718107861413889)
and how to use functions.
5. Learn [how to use arrays](https://www.gnu.org/software/bash/manual/bash.html#Arrays).
6. Use [ShellCheck](https://shellcheck.net). 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`, not `hello.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"`.