[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH 18/39] backup-files: Make input methods mutually excl
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH 18/39] backup-files: Make input methods mutually exclusive |
Date: |
Sat, 19 Mar 2011 10:52:48 +0100 |
User-agent: |
quilt/0.48-17.1 |
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 <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
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] [PATCH 00/39] Reimplement backup-files in bash, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 03/39] BSD compatibility: cp, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 02/39] BSD compatibility: stat, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 21/39] backup-files: Drop curly braces, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 07/39] backup-files: Skip test for file presence, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 18/39] backup-files: Make input methods mutually exclusive,
Jean Delvare <=
- [Quilt-dev] [PATCH 25/39] backup-files: Separate function restore_all, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 26/39] backup-files: Quick exit when unlinking is not needed, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 13/39] backup-files: Split code to sparate functions, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 24/39] backup-files: Avoid negations, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 14/39] backup-files: Mass reindent, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 01/39] Make backup-files a shell script, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 22/39] backup-files: Check if backup exists, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 12/39] backup-files: Simplify find loop, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 15/39] backup-files: Optimize restore, Jean Delvare, 2011/03/19