added pager at end, so we don't have to always combine the listing with less.
authorChris Koeritz <fred@gruntose.com>
Wed, 3 Oct 2012 20:29:01 +0000 (16:29 -0400)
committerChris Koeritz <fred@gruntose.com>
Wed, 3 Oct 2012 20:29:01 +0000 (16:29 -0400)
scripts/archival/listarch.sh

index 88cc9678820f27857bcf1bde600aaf2b63de3495..c21d5d689a07669bfafc6c6bf15b2a7bbaae3e42 100644 (file)
@@ -24,6 +24,16 @@ if [ ! -f "$archive_file" ]; then
   exit 1
 fi
 
+if [ -z "$PAGER" ]; then
+  PAGER=$(which less)
+  if [ -z "$PAGER" ]; then
+    PAGER=$(which more)
+    if [ -z "$PAGER" ]; then
+      PAGER="cat"
+    fi
+  fi
+fi
+
 # save where we started out.
 ORIGINATING_FOLDER="$( \pwd )"
 
@@ -45,12 +55,12 @@ if [[ $archive_file =~ .*\.tar$ \
     || $archive_file =~ .*\.tgz$ \
     || $archive_file =~ .*\.ova$ \
     ]]; then
-  tar -tf $archive_file
+  tar -tf $archive_file | $PAGER
 elif [[ $archive_file =~ .*\.zip$ \
     || $archive_file =~ .*\.epub$ \
     || $archive_file =~ .*\.odt$ \
     || $archive_file =~ .*\.jar$ \
     || $archive_file =~ .*\.war$ \
     ]]; then
-  unzip -v $archive_file
+  unzip -v $archive_file | $PAGER
 fi