From 27225be1a371d7216d96d80f08e5290accfb9b66 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 22 Nov 2010 15:18:10 -0800 Subject: [PATCH] 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. --- scripts/backup.in | 12 ++++++------ scripts/restore.in | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) 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 -- 2.45.2