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!



Reply via email to