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 through 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.
    • Argbash says:
      • argbash>=2.7.0 can generate code that uses getopts in the POSIX mode, so there is no reason any longer to write that code manually.
  • 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 provides 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 necessary.
  • 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.
  • docopt: Umbrella project of parsing code modules for various languages. The interface is based on help messages: http://docopt.org/ The shell interface is called docopts and it is implemented as a standalone executable (in fact a Python script) that consumes the help message of the script it is used in, passed arguments, and exposes collected values via environmental variables.
    • Pros:
      • The help message as an interface is convenient.
    • Cons:
      • You need docopts installed in every environment where you run scripts that use it.
    • Argbash says:

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 learning resources!