vothanhkiet / unix-shell-script-tactics

Unix shell script tactics - best practices style guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unix shell script tactics - best practices style guide

This Unix shell script style guide helps us write better Unix shell script code for speed, security, stability, and portability.

This guide is by SixArm.com, a software consultancy. Our customers use shell scripts within a wide variety of Unix shells, so we aim for POSIX for simple scripts.

Highlights:

Recommendations (details of these are TODO):

  • Quote liberally such as "$var" instead of just $var, for safety.
  • Bulletproof scripts to handle characters such as a quote, newline, leading dash.
  • Enable a user to customize commands by using env vars such as ${FOO:-foo}.
  • Create temporary files by using mktemp instead of tempfile et. al.

Demo:

Topics

Argument parsing:

Environment variables:

Directories:

Files:

References:

Conventions:

Control flow statements:

Functions:

Command snippets:

Compatibilities:

PostgreSQL psql:

About

Unix shell script tactics - best practices style guide

License:Other


Languages

Language:Shell 62.4%Language:Makefile 37.6%