💾 Archived View for zvava.org › wiki › sh.gmi captured on 2023-07-22 at 16:21:17. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-07-10)
-=-=-=-=-=-=-
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 format `#!interpreter [args]`
so if we have script.sh with a shebang to call the sh binary with a few arguments
#!/bin/sh -x -y
echo Hello World!
when we run it with
./script.sh a b
it gets executed as
/bin/sh -x -y ./script.sh a b
→ use the bourne shell, most portable
→ use the bourne shell
→ use the bourne again shell
→ use powershell
→ 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 with more liberal extensions
TODO: write shell script language cheatsheet