vibroverbus
Regular Contributor
Long story short, trying to port a shell script that uses getopts. No getopts on asuswrt, but we have getopt in busybox. Well, as often with busybox implementation.... the doc blows. I'm a pretty good googleborg user and have come up with tons of stuff including a number of of getopts vs getopt posts (several of which are horrible in their own way), but much doesn't seem to apply or work.
So - some getopt examples seem to suggest you can recursively call getopt to load args into a variable until the last arg has been hit - like getopts - but AFAICT that doesn't work at least in the BB implementation...
Is that right? Do you just call getopt once, then just use shift to churn through $1 & $2 ? I found an example or two showing that, as well as a number showing you can use getopt to load a user defined variable, or, OPTS & OPTARG (as getopts does), so its all clear as mud...
So - some getopt examples seem to suggest you can recursively call getopt to load args into a variable until the last arg has been hit - like getopts - but AFAICT that doesn't work at least in the BB implementation...
Is that right? Do you just call getopt once, then just use shift to churn through $1 & $2 ? I found an example or two showing that, as well as a number showing you can use getopt to load a user defined variable, or, OPTS & OPTARG (as getopts does), so its all clear as mud...