This blog points to articles written on http://kirk.webfinish.com. These articles are mainly about shell scripting, PHP, and postgresql on Ubuntu and OS/X.
bash shell script to use getopts with gnu style long positional parameters
Posted 11-03-2009 at 05:04 PM by roybal
Here's a script that will accept --gnu-style-long-parameters and interpret them appropriately.
http://kirk.webfinish.com/2009/10/ba...al-parameters/
http://kirk.webfinish.com/2009/10/ba...al-parameters/
Total Comments 2
Comments
-
Coincidentally, I've just gone through this very exercise. Your approach is an interesting alternative to mine, and I'll bear it mind for the future.
FYI, my approach in this case was to simply use all short options for the script itself, and then convert them to the long options in the case statement. It wouldn't work for something with a large set of options, too messy.
For example, the application takes a long option of --file filename, I use -f in the script:
A quick question, you, and the examples in the docs, use "eval set -- $args". I can't figure out the reason for the eval. Couldn't you simply use "set -- $args" to put the params into $1, $2, etc.Code:case $opts in f) file="--file $OPTARG" ;; esac # call the app app "$file"
Cheers,
NickPosted 11-04-2009 at 06:13 AM by padeen
-
The eval is there because parameters (like long file names with spaces) will get expanded to multiple parameters. I can add quotes around the parameters to "group" them again, but I need the eval to get 'set' to accept the quoted arguments.Quote:
/bitheadPosted 11-17-2009 at 12:46 PM by roybal





