Make the various file list selection methods mutually exclusive. This is the actual usage scheme by quilt, and handling them separately makes the code both clearer and more efficient.
Signed-off-by: Jean Delvare <[email protected]> Reviewed-by: Raphael Hertzog <[email protected]> --- quilt/scripts/backup-files.in | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) --- a/quilt/scripts/backup-files.in +++ b/quilt/scripts/backup-files.in @@ -27,10 +27,9 @@ set -e # name prefix for the backup files must be specified with the -B option. usage () { - echo "Usage: $0 [-B prefix] [-f {file|-}] [-s] [-k] [-t] [-L] [-b|-r|-x] {file|-} ... + echo "Usage: $0 -B prefix [-s] [-k] [-t] [-L] [-b|-r|-x] {-f {file|-}|-|file ...} - Create hard linked backup copies of a list of files - read from standard input. + Create or restore backup copies of a list of files. -b Create backup -r Restore the backup @@ -188,24 +187,22 @@ if [ -n "$OPT_FILE" ]; then | while read nextfile; do $OPT_WHAT "$nextfile" done + exit fi -while [ $# -gt 0 ]; do - case $1 in - -) - find "$OPT_PREFIX" -type f -print \ - | while read - do - $OPT_WHAT "${REPLY#$OPT_PREFIX}" - done - if [ ${PIPESTATUS[0]} != 0 ]; then - exit 1 - fi - ;; - *) - $OPT_WHAT "$1" - ;; - esac +if [ "$1" = - ]; then + find "$OPT_PREFIX" -type f -print \ + | while read + do + $OPT_WHAT "${REPLY#$OPT_PREFIX}" + done + if [ ${PIPESTATUS[0]} != 0 ]; then + exit 1 + fi + exit +fi +while [ $# -gt 0 ]; do + $OPT_WHAT "$1" shift done _______________________________________________ Quilt-dev mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/quilt-dev
