Re: What's cooking in git.git (topics)
- From
Miles Bader <miles.bader@necel.com>
- Date
- Nov 2, 2007, 06:06 UTC
- Message-ID
- <buofxzp18qp.fsf@dhapc248.dev.necel.com>
- In-Reply-To
- <alpine.LFD.0.999.0711011129460.3342@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 7 quoted lines
> So while you can combine flags for *most* programs, you still won't > be able to say things like > > git clean -qdx > > just because that's still a shellscript, and doing any fancy argument > parsing in shell is just painful.
Indeed... but for my personal shell scripts I like to use a construct like the following for parsing args:
while :; do
case "$1" in
... lots of cases to handle normal args ... -[!-]?*)
# split concatenated single-letter options apart
FIRST="$1"; shift
set -- `echo $FIRST | $SED 's/-\(.\)\(.*\)/-\1 -\2/'` "$@"
;; -*)
# unrecognized option
unrec_opt "$1"; exit 1;;
*)
# non-option
break;
esac
doneI'm sure there are problems with it, but it generally seems to work pretty reasonably for short options.
-Miles
-- 97% of everything is grunge