![]() |
what is the best method for reading in arguments?
what is the best method for reading in arguments? How do you guys usually do it?
For example if I had stuff like -r 432 -t -i 5435 etc. |
Are you using Bash?
|
yes. i'm using bash.
I want to read in multiple arguments of unknown length. I found one way that uses a loop with the argument count $#, then uses a case statement to evaluate $1, and then shifts the arguments over to look at the next one. I was just wondering if there were other methods. |
You should look up GETOPTS in the advanced bash scripting guide.
|
Quote:
|
getopts isn't very powerful. Take a look at how prefix (specifically sections 2 through 4) parses arguments. If you want another example, look at fsize.
Note this system is imperfect. Most notibly it doesn't yet support non-option arguments that start with a hyphen. I'll get to this when I have time (a lot of stuff builds up to read after being away over a three day weekend...). I should make a shell based off Bash that incorporates this system in a builtin... |
Okay, I've updated fszie to handle files that start with a hyphen (you have to put -- first to tell it to stop parsing options).
|
| All times are GMT -5. The time now is 9:59 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC