- Do you write
Bashscripts that should accept arguments?
- But they don't since arguments support is a daunting task, because ...
getoptsdoesn't support long options, there is no widely-accepted
Bashmodule to do the task and some solutions don't work on all platforms (Linux, OSX, MSW)...
Argbash a try and stop being terrorized by those pesky arguments! With Argbash, you will get:
- Make your existing script powered by
Argbashin a couple of minutes!
- Fast, minimalistic declaration of arguments your script expects (see below for supported argument types).
- Generate script from definitions once and use it afterwards on all platforms that have
- Definitions will stay embedded in few lines of the script itself (so you can use
Argbashto regenerate the parsing part of your script easily).
- Re-use low-level
Argbash-aware scripts by wrapping them by higher-level
Argbash-aware ones conveniently, without duplicating code.
- Easy installation (optional). Just grab a release, unzip it, go inside and run
cd resources && make install(you may want to run
sudo make install PREFIX=/usr/binfor a system-wide installation).
- Documentation and examples.
This just in: Try argbash online!
Yes, visit our vintage site and start playing with templates like no tomorrow!
What it is
Argbash is not a parsing library, but it is rather a code generator that generates a library tailor-made for your script.
It lets you to describe arguments your script should take and then, you can generate the
You can either include in your script or let
Argbash do it for you (in any case, from then on, you can forget about
Argbash is very simple to use and the generated code is relatively nice to read.
Moreover, argument definitions stay embedded in the script, so when you need to update the parsing logic, you just re-run the
argbash script on the already generated script.
So by writing few comments to your script and running the Argbash's
bin/argbash over it, you will get a
bash script with argument parsing.
See the simple example source template and simple example script for the result.
If you are not into long reading, let
bin/argbash-init generate the template for you.
Following argument types are supported:
- Positional arguments (defaults supported, possibiliy of fixed, variable or infinite number of arguments),
- optional arguments that take one value,
- boolean optional arguments,
- repeated (i.e. non-overwriting) optional arguments,
- incrementing (such as
--verbose) optional arguments and
- action optional arguments (such as
The utility has been inspired by Python's
argparse and the
Read the docs (latest stable version) for more info
bashthat can work with arrays (most likely
bash >= 3.0) (the only requirement for users - i.e. people that only execute scripts and don't make them)
autom4teutility that can work with sets (part of
autoconf >= 2.63suite)
- basic utilities s.a.