Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bash_optparse: advanced option parsing system for bash

133 views
Skip to first unread message

cabal

unread,
Mar 17, 2011, 11:40:32 AM3/17/11
to
Small announcement: as per the subject, I have developed a command
line parsing system for bash somehow similar to python's optparse.
I started using it heavily and find it useful, maybe someone else will
be interested.

1) github repositoy: https://github.com/carlobaldassi/bash_optparse
2) quick explanation with download links: https://github.com/carlobaldassi/bash_optparse/wiki
3) a simple example file: https://github.com/carlobaldassi/bash_optparse/raw/master/doc/example_script_simple

Comments / suggestions are welcome.

Matt

unread,
Apr 8, 2011, 1:46:45 PM4/8/11
to
I downloaded tried bash_optparse. It has everything I've always wanted in option parsing and is lacking in the standard getopt/getopts solutions. The automated help and argument error checking is wonderful! Thank you for making it available.

For relatively simple tasks, I like to keep a file of custom global bash functions rather than a directory of scripts. Some of the functions use getopt for option parsing. Since getopt lacks readability and auto-help, I've been looking for another solution. It would be great to use bash_optparse form a function.

Since bash_optparser calls exit, it can't be used from functions, since exit causes the terminal window to close. After an error within a function, I usually call return, to leave the function, without killing the entire shell.

Can you suggest a low impact work around? If not, would you consider a SETTINGS option for use within functions?

cabal

unread,
Apr 9, 2011, 4:35:45 AM4/9/11
to

Thanks for the feedback!

Concerning the issue about using it from within a function: I'm aware
of this, but I have no workaround to suggest at the moment. Because of
the way bash_optparse works, it is not trivial to come up with an
elegant solution like adding a simple SETTING, either. I shall put
this into my to-do list and think about how this could be addressed; I
hope to have a solution soon.

cabal

unread,
Apr 25, 2011, 7:06:04 PM4/25/11
to
On Saturday, April 9, 2011 10:35:45 AM UTC+2, carlob...@gmail.com wrote:

Update: usage from within functions is now possible. There's an additional example file in the doc directory which demonstrates this. Note: everything seems to work fine in my tests, but I'd still consider this feature as experimental: if anybody tries this, please report any problems which may arise, thanks.

0 new messages