💾 Archived View for zvava.org › wiki › sh.gmi captured on 2023-07-10 at 13:12:06. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
created 2023/06/01 modified 2023/07/08 category info
notes on shell scripting
a shebang or hangbang is the character sequence at the beginning of a script denoting what interpreter to use, it is a hashtag followed by an exclaimation mark then the path to the executable of the interpreter of the scripting language in the following format
#!interpreter [args] so: $ ./script.sh a b → /usr/bin/env sh ./script.sh a b
#!/usr/bin/env sh → use the bourne shell, most portable #!/bin/sh → use the bourne shell #!/bin/bash → use the bourne again shell #!/usr/bin/pwsh → use powershell #!/bin/false → do nothing when called by a user and return a non-zero exit code
the simple difference between sh and bash is that sh is completely portable across all *nix distributions and bash has a few extensions from gnu added to it, there are also other shells that are less common
TODO: write shell script language cheatsheet