Link to this headingBash

Common Problems:

  • Does not stop when issues occur by default (use set -e for error handling)

Link to this headingCommon Vulnerabilities

Link to this headingGlobbing issues

Files as Arguments:

[generalzero@dev test]$ ls --help [generalzero@dev test]$ ls -al total 0 drwxr-xr-x 2 generalzero generalzero 60 Mar 7 17:08 . drwxrwxrwt 20 root root 640 Mar 7 17:08 .. -rw------- 1 generalzero generalzero 0 Mar 7 17:08 --help [generalzero@dev test]$ ls * Usage: ls [OPTION]... [FILE]... List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE with -l, scale sizes by SIZE when printing them; e.g., '--block-size=M'; see SIZE format below

Link to this headingShellcheck

ShellCheck, a static analysis tool for shell scripts

Basic usage:

shellcheck yourscript