From: Paul Eggert Date: Mon, 22 Nov 2010 23:18:10 +0000 (-0800) Subject: scripts: fix option parsing X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=27225be1a371d7216d96d80f08e5290accfb9b66;p=chaz%2Ftar scripts: fix option parsing Problem reported by Dennis Wydra in . * scripts/backup.in: Accept "-l LEVEL". Be more systematic about backslashes inside ``; it shouldn't matter for modern shells but it might matter for older ones. * scripts/restore.in: Likewise. * scripts/backup.in: Adjust implementation of -t/--time to match the new implementation of -l/--level. --- diff --git a/scripts/backup.in b/scripts/backup.in index 6a50e51..37bfed3 100644 --- a/scripts/backup.in +++ b/scripts/backup.in @@ -72,8 +72,9 @@ do --l=*|--le=*|--lev=*|--leve=*|--level=*) DUMP_LEVEL=$optarg ;; + -l?*) DUMP_LEVEL=`expr $option : '-l\(.*\)'`;; -l|--l|--le|--lev|--leve|--level) - prev=$option + prev=--level ;; --verb=*|--verbo=*|--verbos=*|--verbose=*) VERBOSE=$optarg @@ -81,14 +82,13 @@ do -v|--verb|--verbo|--verbos|--verbose) VERBOSE=100 ;; - -v*) VERBOSE=`expr $option : "-v\(.*\)"`;; + -v*) VERBOSE=`expr $option : '-v\(.*\)'`;; --t=*|--ti=*|--tim=*|--time=*) TIME=$optarg ;; - -t) prev=--t;; - -t*) TIME=`expr $option : "-t\(.*\)"`;; - --t|--ti|--tim|--time) - prev=$option + -t?*) TIME=`expr $option : '-t\(.*\)'`;; + -t|--t|--ti|--tim|--time) + prev=--time ;; -V|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "backup (@PACKAGE_NAME@) @VERSION@" diff --git a/scripts/restore.in b/scripts/restore.in index efc320a..2f86bac 100644 --- a/scripts/restore.in +++ b/scripts/restore.in @@ -60,8 +60,9 @@ do --l=*|--le=*|--lev=*|--leve=*|--level=*) DUMP_LEVEL=$optarg ;; + -l?*) DUMP_LEVEL=`expr $option : '-l\(.*\)'`;; -l|--l|--le|--lev|--leve|--level) - prev=$option + prev=--level ;; --verb=*|--verbo=*|--verbos=*|--verbose=*) VERBOSE=$optarg @@ -69,7 +70,7 @@ do -v|--verb|--verbo|--verbos|--verbose) VERBOSE=100 ;; - -v*) VERBOSE=`expr $option : "-v\(.*\)"`;; + -v*) VERBOSE=`expr $option : '-v\(.*\)'`;; -V|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "restore (@PACKAGE_NAME@) @VERSION@" license