Others

Utilities

You want to write a script that does argument parsing and don’t like Argbash or you just want to find out how awesome it really is? Then read throgh this list of influences and/or alternatives!

  • Python argparse: The main inspiration: https://docs.python.org/3/library/argparse.html
    • Pros:
      • Works really well.
      • Has more features.
    • Cons:
      • It is Python, we are bash.
      • It has a strict value restriction turned on (analogous to having ARG_RESTRICT_VALUES([no-option-all]) in every script) that can’t be switched off.
    • Argbash says:
  • bashshflags: The bash framework for argument parsing: https://github.com/kward/shflags
    • Pros:
      • It works great on Linux.
    • Cons:
      • Doesn’t work with Windows bash
      • Doesn’t support long options on OSX.
    • Argbash says:
      • We work the same on all platforms that have bash.
  • getopt: Eternal utility for parsing command-line. This is what powers shflags.
    • Pros:
      • The GNU version can work with long and short optional arguments.
    • Cons:
      • Its use is discouraged — it seems to have some issues, you still need to deal with positional arguments by other means.
  • getopts: bash builtin for parsing command-line.
    • Pros:
      • Being included with bash, it behaves the same on all platforms.
    • Cons:
      • Supports only short optional arguments.
  • EasyOptions: Ruby utility with a bash interface as well as its pure bash implementation: https://github.com/renatosilva/easyoptions
    • Pros:
      • Very simple to use.
      • Very elegant.
    • Cons:
      • You have to distribute easyoptions.sh with your script.
      • The library itself proides only very basic functionality.
      • The project does not seem to have any tests (as of 07/2016).
    • Argbash says:
      • We have more of nice features.
      • We offer an option to produce battery-included scripts.
      • Our declarations as not so elegant, but they are not bad either.
      • The parsing part of the script generated by Argbash is only as complex as neccessary.
  • bash-modules - module argument: bash-modules aims to become a standard bash framework and comes with an argument-parsing treat: https://github.com/vlisivka/bash-modules
    • Pros:
      • Seems to have nice features.
    • Cons:
      • bash-modules have to be available at run-time to run the script.
      • The documentation is poor (as of 07/2016).
    • Argbash says:
      • We have good documentation with examples.
      • We offer an option to produce battery-included scripts.

Learning resources

Do you want to write the argument-parsing part of your script yourself or you want to improve Argbash? Then read through this list of high-quality learing resources!