From: Miles Bader Date: Fri, 02 Nov 2007 15:13:36 GMT Subject: Re: What's cooking in git.git (topics) Message-ID: <87d4usaden.fsf@catnip.gol.com> In-Reply-To: I previously wrote: > Indeed... but for my personal shell scripts I like to use a construct > like the following for parsing args: In a little more detail, the arg-splitting case: > -[!-]?*) > # split concatenated single-letter options apart > FIRST="$1"; shift > set -- `echo $FIRST | $SED 's/-\(.\)\(.*\)/-\1 -\2/'` "$@" > ;; Just strips off the first short option and stuffs it back into the list of args to parse, so "-xyz" becomes "-x -yz". That way short args get split by default, but short-args with an appended value still work correctly. So, for instance, if in the above example, "-y" takes an argument, then there'd be a switch case case for "-y*") which would consume the "-yz" before it reached the arg-splitting case; if "-y" _doesn't_ take an argument, then "-yz" would get split in turn, becoming "-y -z". -Miles -- /\ /\ (^.^) (")") *This is the cute kitty virus, please copy this into your sig so it can spread.