System · Bash Script With Options

Sep 16, 2023 | Tech Software

Preface

Bash scripts are useful tools for automating the build and configuration of software projects. Scripts that accept input options and arguments offer additional flexibility. This post presents such a template, for reference, see Adding arguments and options to your Bash scripts , A Bash Template is very Useful, and Explaining shift OPTIND.

Known Issues

  • $bash template-arguments.bash -b -a -f will be parsed as $bash template-arguments.bash -b -a "-f", instead of identifying -f as an invalid option;
  • $bash template-arguments.bash -bafoo will be parsed as $bash template-arguments.bash -b -a foo, instead of identifying -bafoo as an invalid option.