Ticket #1477: incorrect detection of compressed patchfs

UseCase:
 * rename any patch file into patch_file.lzma_tar.patch.gz for example
 * try to enter into renamed file (press Enter key on a file in panel)
 * You'll see error message 'sh: lzma: command not found'

Fix issue:
 * Add -b key into call of 'file' utility (to avoid filename in output)
 * better parse 'file -b' output

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Daniel Borca 2009-08-24 17:41:36 +03:00 committed by Slava Zanko
parent d5167d0e6f
commit ad42905ecf

View File

@ -17,7 +17,7 @@ my $lzma = 'lzma';
my $xz = 'xz';
my $bzip = 'bzip2';
my $gzip = 'gzip';
my $fileutil = 'file';
my $fileutil = 'file -b';
# date parsing requires Date::Parse from TimeDate module
my $parsedates = eval 'require Date::Parse';
@ -74,13 +74,13 @@ sub myin
my ($qfname)=(quotemeta $_[0]);
$_=`$fileutil $qfname`;
if (/lzma/) {
if (/^'*lzma/) {
return "$lzma -dc $qfname";
} elsif (/xz/) {
} elsif (/^'*xz/) {
return "$xz -dc $qfname";
} elsif (/bzip/) {
} elsif (/^'*bzip/) {
return "$bzip -dc $qfname";
} elsif (/gzip/) {
} elsif (/^'*gzip/) {
return "$gzip -dc $qfname";
} else {
return "cat $qfname";
@ -94,13 +94,13 @@ sub myout
my ($sep) = $append ? '>>' : '>';
$_=`$fileutil $qfname`;
if (/lzma/) {
if (/^'*lzma/) {
return "$lzma -c $sep $qfname";
} elsif (/xz/) {
} elsif (/^'*xz/) {
return "$xz -c $sep $qfname";
} elsif (/bzip/) {
} elsif (/^'*bzip/) {
return "$bzip -c $sep $qfname";
} elsif (/gzip/) {
} elsif (/^'*gzip/) {
return "$gzip -c $sep $qfname";
} else {
return "cat $sep $qfname";