Skip to content

taiwan-jjl/reasonable-shell-script

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 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 and how to use functions.
  5. Learn how to use arrays.
  6. Use ShellCheck. It's helpful for learning, not just for going after production code.

Common conventions that minimize annoyances:

  • Executable files should have no extension. It's hello, not hello.sh.
  • Environment variables should use all-caps e.g. "$USER". Ordinary shell variables should use lowercase e.g. "$name".

About

Because shell scripts don't have to be terrible

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%