Skip to content

jamespwilliams/strictbash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

strictbash

strictbash offers a convenient way of enabling the (unofficial) Bash Strict Mode.

Also, with one flag, strictbash allows you to pass your script through shellcheck before it's run.

strictbash is an experiment and probably shouldn't be used in production :).

Default strictbash usage

Usage

Using strictbash is straightforward: simply use the following shebang:

#!/usr/bin/env strictbash

This is equivalent to:

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

To additionally run shellcheck before your script is invoked:

#!/usr/bin/env -S strictbash --shellcheck

To disable setting the IFS to \n\t, pass --no-ifs:

#!/usr/bin/env -S strictbash --no-ifs

Strictbash being used with the shellcheck option

Installation

strictbash is a single bash script with no dependencies (unless you want to use its shellcheck feature, in which case you must install shellcheck). Install by:

curl -O https://raw.githubusercontent.com/jamespwilliams/strictbash/main/strictbash
# move somewhere on your $PATH

If you have Nix (and flakes enabled), you can try it out with:

nix shell github:jamespwilliams/strictbash

or install with

nix profile install github:jamespwilliams/strictbash

Test file

Here's a file you can paste somewhere as a test:

#!/usr/bin/env -S strictbash --shellcheck

echo $undefined

About

Enable Bash "strict mode" & run shellcheck via a shebang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors