Skip to content

brlin-tw/GNU-Bash-Shell-Script-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GNU Bash Shell Script Template

This project's current build status on Travis CI
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

Template Selection Menu in Dolphin FM(KDE)

Features

Debugger-friendly

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.

Developer-friendly

We want developers to fucus on their code instead of the template's, so we moved developer related code like the initfunction, 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.

Beginner-friendly

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.

Full of Functionalities

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 script
      • My Awesome Script.bash if the script is in the executable search PATHs (only in full variant)
      • ${0}otherwises.
    • RUNTIME_COMMANDLINE_PARAMETERS
      An array of command-line parameters

Demonstration - Runtime Dependency Checking.png

Demonstration - Command-line Argument Parsing and Help Message

Demonstration - EXIT Trap and Terminal Pausing

Space and non-ASCII Characters Friendly

Script won't broke in an exotic environment.

Unsafe Path Friendly

With Installer that can Install Templates to XDG-compliant File Manager Applications

Supports:

  • Dolphin
  • GNOME Files
  • Thunar
  • and more...(as long as they are compliant)

Need More or Less? You're Covered

The following variants are provided:

Verified, as Always

The code is continuously verified by ShellCheck to not containing any potential pitfalls.

Conforming Specifications

References

Some information used to improve the project:

Software Dependencies

Runtime Dependencies

Software required to run the product:

For fetching script names and paths

Development Dependencies

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

Download Software

Please refer the releases page for ready to use software.

Intellectual Property License

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

Similar projects that we may benefit from: