💾 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

View Raw

More Information

➡️ Next capture (2023-07-22)

-=-=-=-=-=-=-

🏡 go home...

📚 go back...

shell

thumbnail (sh.png)

created  2023/06/01
modified 2023/07/08
category info

notes on shell scripting

*nix

batch

shebang

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

examples

#!/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

bourne vs bourne again shell

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

cheat sheet

TODO: write shell script language cheatsheet