Its a quadruple bug!

The two Stas found, PLUS the test is wrong.  Its testing:
        # change a file to execute-only
        @ARGV = ( 0100, 'ecmdfile' );
        ExtUtils::Command::chmod();

but that doesn't really simulate a command line call.  0100 becomes octal.
A real "perl -MExtUtils::Command=chmod -e chmod 0100 <files>" would have
0100 coming in as a string.  So the test needs to be fixed.

And there's *another* mistake in the test.  My changes to Command.pm
weren't showing up because it was accidentally using the installed
ExtUtils::Command.  The "use_ok" came after the "chdir 't'" which causes
odd problems when you have blib/lib in @INC.

Good catch, Stas!


----- Forwarded message from Stas Bekman <[EMAIL PROTECTED]> -----

From: Stas Bekman <[EMAIL PROTECTED]>
Date: Fri, 07 Mar 2003 14:38:13 +1100
To: [EMAIL PROTECTED]
Subject: [Fwd: [patch] double bug in ExtUtils::Command::chmod]
Delivered-To: [EMAIL PROTECTED]
Organization: Hope, Humanized
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826
X-Accept-Language: en-us, en

Hi Michael, not sure whether you've missed this one. Thanks.

-------- Original Message --------
Subject: [patch] double bug in ExtUtils::Command::chmod
Date: Sat, 01 Feb 2003 22:40:03 +1100
From: Stas Bekman <[EMAIL PROTECTED]>
Organization: Hope, Humanized
To: [EMAIL PROTECTED]

bug #1

SYNOPSIS says:

perl -MExtUtils::Command -e chmod mode files...

but ExtUtils::Command::chmod is not exported, so the Perl's built-in chmod is
called, without any arguments and it happily returns without doing anything
and without warning anybody.

---

bug #2, the doc says:

    Sets UNIX like permissions 'mode' on all the files.

the mode is something like 0666, though you have to eval the string "0666" as
an octal number before passing it to chmod()

---

finally I've added an example to the doc, to avoid confusion of what kind of
mode is expected.

here is the fix against distro 6.05

--- lib/ExtUtils/Command.pm.old 2002-06-14 06:00:15.000000000 +1000
+++ lib/ExtUtils/Command.pm     2003-02-01 22:31:25.000000000 +1100
@@ -10,7 +10,7 @@
   require Exporter;
   use vars qw(@ISA @EXPORT $VERSION);
   @ISA     = qw(Exporter);
[EMAIL PROTECTED]  = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f);
[EMAIL PROTECTED]  = qw(cp rm_f rm_rf mv cat eqtime mkpath chmod touch test_f);
   $VERSION = '1.04';

   my $Is_VMS = $^O eq 'VMS';
@@ -173,7 +173,7 @@

   =item chmod mode files...

-Sets UNIX like permissions 'mode' on all the files.
+Sets UNIX like permissions 'mode' on all the files. e.g. 0666

   =cut

@@ -181,7 +181,8 @@
   {
    my $mode = shift(@ARGV);
    expand_wildcards();
- chmod($mode,@ARGV) || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!";
+ chmod(oct($mode), @ARGV)
+     || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!";
   }

   =item mkpath directory...


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


----- End forwarded message -----

-- 

Reply via email to