[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getopts - mutually exclusive flags

From: Chris Jones
Subject: getopts - mutually exclusive flags
Date: Sat, 25 Oct 2008 23:58:10 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

How do I handle mutually exclusive flags with getopts?

I'm writing a script that normally runs from cron and backs up my hard

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

Although this makes sense - i.e. run the monthly and then run the
daily.. I'd still be interested in an exclusive OR of my two flags.

Incidentally, I am also curious of the "getopts" way to handle the
absence of _any_ flags.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]