On Sun, Oct 26, 2008 at 08:12:58AM EDT, Chris Jones wrote: > How do I handle mutually exclusive flags with getopts? > > I'm writing a script that normally runs from cron and backs up my hard > drive. > > But I'd like to be able to run it manually and specify via flags the > backup I want to run - daily/incremental or monthly/full. > > $ backup -d # daily backup > $ backup -m # monthly .. > > So far my best effort still finds the following acceptable: > > $ backup -dm > > I'm trying to use getopts to implement an exclusive OR of the two > options. > > Incidentally, I am also curious of the "getopts" way to handle the > absence of _any_ flags. > > Or am I using the wrong tool for the job? > > Thanks!
Sorry about triple-post .. seems all three were delayed some 24+ hours before they made it to the list. Hopefully my apologies above won't be delayed :-)