Skip to content

Instantly share code, notes, and snippets.

@artginzburg
Last active January 2, 2023 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artginzburg/d8e6bc13c8e329a53b6a277c5c9b7fd9 to your computer and use it in GitHub Desktop.
Save artginzburg/d8e6bc13c8e329a53b6a277c5c9b7fd9 to your computer and use it in GitHub Desktop.
Bash ruleset with real-world examples

Note: I'll add my opinion to individual rules once I experience enough of the issue related to it.

  1. Full paths to binaries.

    Some systems do not have default aliases for some of the CLIs installed (or that may be installed by the user). So it is quite often required to specify the absolute binary path.

    Example
    -sudo sed -n '3,5p' textfile.txt
    +sudo /usr/bin/sed -n '3,5p' textfile.txt

    Real-world example: artginzburg/sudo-touchid#13, when the sed command was installed in GNU operating system.

    A more popular example is the Docker Desktop application that specifies /bin/bash instead of bash when the user tries to open a container in the terminal, even if it is not actually required in the user's system.

    To get the absolute path of a command for your system, use the which command. Example: which sudo-touchid => /opt/homebrew/bin/sudo-touchid. Note that a command may have many different paths in some cases, such as: different operating systems, different versions of the same OS, or if the command was installed using a non-standard package manager, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment