add note about license
[small-misc-bash] / ex
diff --git a/ex b/ex
index 7859db3276e75e76486c8f17064e72d365785d39..dd81d1ee616ccef6f00f40fe0a076da5fa7c2df1 100755 (executable)
--- a/ex
+++ b/ex
@@ -1,5 +1,12 @@
 #!/bin/bash
-# Copyright (C) 2014 Ian Kelling
+# I, Ian Kelling, follow the GNU license recommendations at
+# https://www.gnu.org/licenses/license-recommendations.en.html. They
+# recommend that small programs, < 300 lines, be licensed under the
+# Apache License 2.0. This file contains or is part of one or more small
+# programs. If a small program grows beyond 300 lines, I plan to switch
+# its license to GPL.
+
+# Copyright 2024 Ian Kelling
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -13,6 +20,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+
 ex() {
   local help="Usage: ex [--help|-q] FILE...
 Extract many types of files
@@ -33,7 +41,7 @@ Note: dtrx (package & command) extracts most of these plus some others."
       shift
       ;;
   esac
-  local x super restore_nullglob f
+  local x super restore_nullglob f cmd
   for x in "$@"; do
     case "$x" in
       # tars first, so they are higher pri than non-tar extensions
@@ -53,20 +61,33 @@ Note: dtrx (package & command) extracts most of these plus some others."
         $quiet || echo tar Jxf "$x"
         tar Jxf "$x"
         ;;
+      *.tar.zst )
+        $quiet || echo tar -I unzstd -xf "$x"
+        tar -I unzstd -xf "$x"
+        ;;
+      *.zst )
+        $quiet || echo unzstd "$x"
+        unzstd "$x"
+        ;;
       *.xz)
-        $quiet || echo xz -d "$x"
-        xz -d "$x"
+        $quiet || echo pixz -d "$x"
+        pixz -d "$x"
         ;;
       *.7z )
-        $quiet || echo 7za x "$x"
-        7za x "$x"
+        if type -p 7za &>/dev/null; then
+          cmd=7za
+        else
+          cmd=7zr
+        fi
+        $quiet || echo 7zr x "$x"
+        $cmd x "$x"
         ;;
       *.bz2 )
         $quiet || echo bunzip2 "$x"
         bunzip2 "$x"
         ;;
       *.deb )
-        $quiet || ar x "$x"
+        $quiet || echo ar x "$x"
         ar x "$x"
         restore_nullglob=false
         if ! shopt -q nullglob; then
@@ -85,13 +106,22 @@ Note: dtrx (package & command) extracts most of these plus some others."
             *.xz)
               $quiet || echo tar xJf $f
               tar xJf $f
+              rm -f $f
+              ;;
+            *.zst)
+              $quiet || echo tar -I unzstd -xf $f
+              tar -I unzstd -xf $f
+              rm -f $f
               ;;
             *.gz)
               $quiet || echo tar xzf $f
               tar xzf $f
+              rm -f $f
+              ;;
+            *)
+              echo "ex: ERROR: file i didnt expect: $f"
               ;;
           esac
-          rm -f $f
         done
         ;;
       *.dsc)