aboutsummaryrefslogtreecommitdiffstats
path: root/compress_files
diff options
context:
space:
mode:
Diffstat (limited to 'compress_files')
-rwxr-xr-xcompress_files8
1 files changed, 6 insertions, 2 deletions
diff --git a/compress_files b/compress_files
index d95000e..90d092b 100755
--- a/compress_files
+++ b/compress_files
@@ -7,6 +7,7 @@ use warnings;
use Cwd;
use File::Find;
use File::Basename;
+use Fcntl ':mode';
my $ext = $ARGV[0] ||= '.gz';
die "Unknown extension $ext" unless $ext =~ /^\.(?:gz|bz2|lzma)$/;
@@ -123,8 +124,11 @@ foreach (@files) {
}
if (@f) {
- # Make executables not be anymore.
- xargs(\@f, "chmod", "a-x");
+ # drop executable bits
+ foreach my $file (@f) {
+ my $mode = (stat($file))[2];
+ chmod $mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH, $file;
+ }
my @command = $ext eq '.gz' ? qw/gzip -9f/
: $ext eq '.bz2' ? qw/bzip2 -9f/