Skip to content

tal-sealsecurity/bash_scripts

Repository files navigation

tested on debian:13 - version 5.2.37 MacOs - version 3.2.57

offical documentation: https://www.gnu.org/software/bash/manual/html_node/index.html

rules of thumbs google style: https://google.github.io/styleguide/shellguide.html more info: https://github.com/awesome-lists/awesome-bash

general decision in bash

  • unguarded bash file = one function
  • bash usually should have main and functions
  • bash file should be independant
  • source is used when configuration is required, or overwrite is needed. otherwise prefer a seperate call
  • add testing to your files, example framework bat-core
  • use shellcheck

sh generic guard

if (return 2>/dev/null); then
    # this file is called directly
fi

Bash specific guard

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
    main "$@"
fi

About

bash script and best practices

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages