From e4efed6d1612fd52327c6e3002880baf398d1db6 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Thu, 8 May 2008 17:11:57 +0000 Subject: no more external chmod command use --- compress_files | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'compress_files') 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/ -- cgit v1.2.1