From 0ee49b548b0987edae2e5a19a279c82012923263 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 30 Mar 2015 16:51:04 -0400 Subject: [PATCH] extended list and search and test arch commands in same way as unpack, to handle 7z and rar files. --- scripts/archival/list_arch.sh | 15 +++++++++++++++ scripts/archival/test_arch.sh | 14 ++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/scripts/archival/list_arch.sh b/scripts/archival/list_arch.sh index eba1fc8f..2d5b6b1b 100644 --- a/scripts/archival/list_arch.sh +++ b/scripts/archival/list_arch.sh @@ -47,6 +47,7 @@ if [ ! -f "$archive_file" ]; then fi fi +save_err=1 if [[ $archive_file =~ .*\.tar$ \ || $archive_file =~ .*\.tar\.gz$ \ || $archive_file =~ .*\.tar\.bz2$ \ @@ -57,6 +58,7 @@ if [[ $archive_file =~ .*\.tar$ \ || $archive_file =~ .*\.snarf$ \ ]]; then tar -tf $archive_file | $PAGER + save_err=${PIPESTATUS[0]} elif [[ $archive_file =~ .*\.zip$ \ || $archive_file =~ .*\.epub$ \ || $archive_file =~ .*\.odt$ \ @@ -64,4 +66,17 @@ elif [[ $archive_file =~ .*\.zip$ \ || $archive_file =~ .*\.war$ \ ]]; then unzip -v $archive_file | $PAGER + save_err=${PIPESTATUS[0]} +elif [[ "$archive_file" =~ .*\.7z$ ]]; then + 7z l "$archive_file" | $PAGER + save_err=${PIPESTATUS[0]} +elif [[ "$archive_file" =~ .*\.rar$ ]]; then + rar l "$archive_file" | $PAGER + save_err=${PIPESTATUS[0]} fi + +if [ $save_err -ne 0 ]; then + echo "There was a failure reported while listing: $archive_file" + exit 1 +fi + diff --git a/scripts/archival/test_arch.sh b/scripts/archival/test_arch.sh index be1fddb4..1a37be2b 100644 --- a/scripts/archival/test_arch.sh +++ b/scripts/archival/test_arch.sh @@ -37,6 +37,7 @@ if [ ! -f "$archive_file" ]; then fi fi +save_err=1 if [[ $archive_file =~ .*\.tar$ \ || $archive_file =~ .*\.tar\.gz$ \ || $archive_file =~ .*\.tar\.bz2$ \ @@ -47,6 +48,7 @@ if [[ $archive_file =~ .*\.tar$ \ || $archive_file =~ .*\.snarf$ \ ]]; then tar -tf $archive_file &>/dev/null + save_err=$? elif [[ $archive_file =~ .*\.zip$ \ || $archive_file =~ .*\.epub$ \ || $archive_file =~ .*\.odt$ \ @@ -54,12 +56,16 @@ elif [[ $archive_file =~ .*\.zip$ \ || $archive_file =~ .*\.war$ \ ]]; then unzip -t $archive_file &>/dev/null -else - # we don't know this as an archive. - exit 0 + save_err=$? +elif [[ "$archive_file" =~ .*\.7z$ ]]; then + 7z t "$archive_file" &>/dev/null + save_err=$? +elif [[ "$archive_file" =~ .*\.rar$ ]]; then + rar t "$archive_file" &>/dev/null + save_err=$? fi -if [ $? -ne 0 ]; then +if [ $save_err -ne 0 ]; then echo "** failure while testing: $archive_file" exit 1 else -- 2.34.1