changeset 37:1afdf186b65e

added error message for empty list file
author casties
date Fri, 23 Jun 2006 11:58:17 +0200
parents 9eb746dc69f8
children 7bf843ac256b
files archivemany.sh
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/archivemany.sh	Fri Jun 23 11:49:06 2006 +0200
+++ b/archivemany.sh	Fri Jun 23 11:58:17 2006 +0200
@@ -1,13 +1,13 @@
 #!/bin/bash
 
-VERSION="archivemany V0.2 (23.9.2005 ROC)"
+VERSION="archivemany V0.3 (23.6.2006 ROC)"
 
 #set -x
 
 if [ -z "$1$2" ]
 then
     echo $VERSION
-    echo "use: $0 docdir dirlist"
+    echo "use: $0 docdir dirlist [params...]"
     echo "  Archives the directories given in the file dirlist inside docdir."
     exit 1
 fi
@@ -17,7 +17,6 @@
 PARAM1="$3"
 PARAM2="$4"
 PARAM3="$5"
-CNT="1"
 
 if [ ! -d $BASEDIR ]
 then
@@ -31,8 +30,12 @@
     exit 1
 fi
 
-cat $DIRLIST | while read DIR
+CNT=0
+
+# read directories from DIRLIST
+while read DIR
 do
+    CNT=$(( $CNT + 1 ))
     if [ -d "$BASEDIR/$DIR" ]
     then
 	echo "archiving document $CNT: $DIR..."
@@ -44,7 +47,11 @@
 	    # abort?
 	fi
     else
-	echo "ERROR: document directory $BASEDIR/$DIR not found!"
+	echo "$CNT ERROR: document directory $BASEDIR/$DIR not found!"
     fi
-    CNT=$(( $CNT + 1 ))
-done
+done < $DIRLIST
+
+if [ $CNT = 0 ]
+then
+    echo "ERROR: the list file $DIRLIST seems to be empty!"
+fi