Skip to content

Files

Latest commit

 

History

History
28 lines (17 loc) · 881 Bytes

SC1035.md

File metadata and controls

28 lines (17 loc) · 881 Bytes

Pattern: Missing space in shell script

Issue: -

Description

Bourne shells are whitespace sensitive. Adding or removing spaces can drastically alter the meaning of a script.

Example of incorrect code:

if ![-z foo ]; then true; fi # if command `[-z' w/ args `foo', `]' fails..

Example of correct code:

if ! [ -z foo ]; then true; fi # if command `[' w/ args `-z', `foo', `]' fails..

Exceptions

ShellCheck does not understand Bash History Expansion, an interactive shell feature also using ! (such as !! to expand to the previous command).

These features are disabled by default in shells and very rarely used in scripts, but may occasionally be found in interactively sourced files like .bashrc. Please ignore the error in these cases.

Further Reading