Fixed reversed matching order of the extensions list
authorshort <>
Fri, 28 Jun 2002 01:01:35 +0000 (01:01 +0000)
committershort <>
Fri, 28 Jun 2002 01:01:35 +0000 (01:01 +0000)
Extraction-overwriting cowardly no longer supported
 - fixes/workarounds flaw in FORMAT_TAR_GZ with already-existing content inside
Fixed FORMAT_TAR_GZ && vs. || bash bug for non-archive-dir-ed archives

bin/exx

diff --git a/bin/exx b/bin/exx
index d176d27..12de60d 100755 (executable)
--- a/bin/exx
+++ b/bin/exx
@@ -8,7 +8,7 @@ use warnings;
 use IO::Handle;
 use Cwd qw(chdir cwd);
 
-use constant FORMAT_TAR_GZ=>'tar xzf $pathname;i=`echo *`;echo "$i"|grep -q " " || test * = $base &&'
+use constant FORMAT_TAR_GZ=>'tar xzf $pathname;i=`echo *`;echo "$i"|grep -q " " || test * != $base ||'
                             .'(mv "$i" "$i".$$;(set +x;mv "$i".$$/* .);rmdir "$i".$$)';
 use constant FORMATS=>{
        "rpm"    =>'rpm2cpio $pathname|cpio -id --quiet',       #-v #FIXME: --sparse doesn't work, why?
@@ -30,7 +30,7 @@ die "Syntax: $0 <pathname((".join("|",map(".$_",sort keys %{+FORMATS})).")|=<ext
 my $origdir=cwd;
 for my $fname (@ARGV) {
        my @parsed;
-       for my $fmt (sort { length $a<=>length $b; } keys %{+FORMATS}) {
+       for my $fmt (sort { length $b<=>length $a; } keys %{+FORMATS}) {
                (my $fmtt=$fmt)=~s/(\W)/\\$1/g;
                last if @parsed=$fname=~m#^(.*?)([^/]+)([.=])($fmtt)$#i;
                }
@@ -44,7 +44,9 @@ for my $fname (@ARGV) {
                } while ($cmdtry);
        -r $pathname && !-d $pathname or die "Archive not readable: $pathname";
        my($extdir)=(-e $base && !-d $base ? "$base.dir" : $base);
-       -d $extdir or mkdir $extdir or die "Unable to create directory \"$extdir\": $!";
+       # Extraction-overwriting cowardly not supported:
+                       # -d $extdir or ...
+       mkdir $extdir or die "Unable to create directory \"$extdir\": $!";
        chdir $extdir or die "Unable to chdir to \"$extdir\": $!";
        $pathname="../$pathname" if $pathname!~m#^/#;
        $path    ="../$path"     if $path    !~m#^/#;