help-gnu-utils
[Top][All Lists]
Advanced

[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: Sun, 26 Oct 2008 08:12:58 -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
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

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