diff options
author | Dave Reisner <d@falconindy.com> | 2011-08-17 03:35:57 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-08-18 10:11:27 +0200 |
commit | e652dc8085314a1002305494078e4f276448e4a9 (patch) | |
tree | 3bed002880570e8ce3900a3b6cd73ff5aa8dc59a | |
parent | ba4f28cc43ce217ba19187a1dc79d72ca72ba413 (diff) | |
download | devtools-e652dc8085314a1002305494078e4f276448e4a9.tar.gz devtools-e652dc8085314a1002305494078e4f276448e4a9.tar.xz |
commitpkg: use getopts to parse options
Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
-rwxr-xr-x | commitpkg | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -98,15 +98,17 @@ done # see if any limit options were passed, we'll send them to rsync rsyncopts=(-e ssh -p --chmod=ug=rw,o=r -c -h -L --progress --partial -y) -if [ "$1" = '-l' ]; then - rsyncopts+=("--bwlimit=$2") - shift 2 -fi - -if [ "$1" = "-a" ]; then - commit_arch=$2 - shift 2 -fi +while getopts ':l:a:' flag; do + case $flag in + l) rsyncopts+=("--bwlimit=$2") ;; + a) commit_arch=$2 ;; + :) echo "option requires an argument -- '$OPTARG'" >&2 + exit 1 ;; + \?) echo "invalid option -- '$OPTARG'" >&2 + exit 1 ;; + esac +done +shift $(( OPTIND - 1 )) if [ -n "$(svn status -q)" ]; then echo -n 'committing changes to trunk...' |