This project provides easy-to-use shell script templates for GNU Bash for users to create new scripts.
https://github.com/Lin-Buo-Ren/GNU-Bash-Shell-Script-Template
Local debuggers need fresh livers, we made scripts more error-proof and bug-aware by bailing out whenever a potential scripting error is found.
Secure programming paradigms like Unofficial Bash Strict Mode and Defensive BASH Programming are incorporated into the template design.
We want developers to fucus on their code instead of the template's, so we moved developer related code like the init
function, print_help_message
function and process_commandline_arguments
function to the start of the script and rest of the support code at the bottom.
The template is fully versioned at the bottom of the script, which is useful to upgrade your script to new template versions for new features and fixes.
The code is documented with essential pointers for beginner to lookup with, like relevant GNU Bash manual sections, Stack Overflow answers and Bash Hackers Wiki articles.
We have incorporated the following features into the templates, so that user don't need to recreate wheels.
- Integrated runtime dependency checking
- ERR/EXIT/INT traps for exception handling
- Command-line argument parsing with GNU long variant option support
--help
message printing- Frequently used primitive variables
- RUNTIME_EXECUTABLE_PATH
/home/username/somewhere/My Awesome Script.bash
- RUNTIME_EXECUTABLE_FILENAME
My Awesome Script.bash
- RUNTIME_EXECUTABLE_NAME
My Awesome Script
- RUNTIME_EXECUTABLE_DIRECTORY
/home/username/somewhere
- RUNTIME_COMMANDLINE_BASECOMMAND
A guessed command string that user used to run the scriptMy Awesome Script.bash
if the script is in the executable searchPATH
s (only in full variant)${0}
otherwises.
- RUNTIME_COMMANDLINE_PARAMETERS
An array of command-line parameters
- RUNTIME_EXECUTABLE_PATH
Script won't broke in an exotic environment.
Supports:
- Dolphin
- GNOME Files
- Thunar
- and more...(as long as they are compliant)
The following variants are provided:
- PRIMITIVE
The recommended variant for regular use, core functionalities included. - MILIMALISTIC
If you want it more simpler and don't mind recreating a few more wheels. - FULL
Hundreds of lines of support code, including additional features like:- Stacktrace printing
- Multiple installation configuration support: Standalone/SHC/FHS, conforming to the Flexible Software Installation Specification
- Utility functions like
meta_util_array_shift
- ...and more
- SOURCE'D
Template for source'd code, with include guard support - VANILLA.BASH
Vanilla.bash* is a fast, lightweight, backward compatible template for building incredible, powerful GNU Bash applications.
The code is continuously verified by ShellCheck to not containing any potential pitfalls.
- Use the Unofficial Bash Strict Mode (Unless You Looove Debugging)
http://redsymbol.net/articles/unofficial-bash-strict-mode/ - Defensive BASH programming - Say what?
http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/ - Shebang (Unix) - Wikipedia
https://en.wikipedia.org/wiki/Shebang_(Unix) - Flexible Software Installation Specification
https://github.com/Lin-Buo-Ren/Flexible-Software-Installation-Specification
Some information used to improve the project:
Software required to run the product:
For fetching script names and paths
Software required to develop the product:
For implementing script version injection
For revision management etc.
For various pre-commit hooks checking many aspects in the project and commit verification during continuous integration.
To check any potential problems in the script
Please refer the releases page for ready to use software.
GNU General Public License v3+ with an exception of only using this software as a template of a shell script(which you can use any license you prefer, attribution appreciated)
This means that GPL is enforced only when you're making another "shell script template" using this software, which you're demanded to also using GPL for your work
Similar projects that we may benefit from: