retired bash version of change prefix in favor of cleaned up retread of change suffix.
[feisty_meow.git] / scripts / archival / unpack.sh
index 744d354880bb8c7e472c3615cc0ff3b940ce584f..6670f489f8b408da83baa6983006bd1cb0a398d6 100644 (file)
@@ -25,7 +25,8 @@ if [ ! -f "$archive_file" ]; then
 fi
 unpack_dir="$1"; shift
 if [ -z "$unpack_dir" ]; then
-  unpack_dir=$(echo arch_$(basename $archive_file) | sed -e 's/^\([^\.]*\)\..*/\1/')
+  all_but_last="$(echo "$(basename $archive_file)" | sed -e 's/\([\^.]*\)\.[^\.]*$/\1/')"
+  unpack_dir="arch_${all_but_last}"
 fi
 
 if [ ! -d "$unpack_dir" ]; then
@@ -58,6 +59,7 @@ if [[ $archive_file =~ .*\.tar$ \
     || $archive_file =~ .*\.oar$ \
     || $archive_file =~ .*\.tgz$ \
     || $archive_file =~ .*\.ova$ \
+    || $archive_file =~ .*\.snarf$ \
     ]]; then
   tar -xf $archive_file &>/dev/null
 elif [[ $archive_file =~ .*\.zip$ \