[Koha-devel] chmod

dbkliv dbkliv at netscape.net
Fri Jul 4 09:26:05 CEST 2003


Matthew Hunt wrote:
> On Wed, Jul 02, 2003 at 11:39:17PM -0700, D Belden K Lyman IV wrote:
> 
>>Removing oct() would be a micro-optimisation at best, and could
>>potentially introduce a hard-to-track-down bug:
>>
>>   1.    my $mode = 0644 ;
>>         chmod( $mode, $file );
>>
>>   2.    chmod( '0644', $file );
>>
>>   3.    chmod( 0644, $file );
>>
>>You need oct() in the first 2 cases.
>>
>>dbkliv
>>
>>[1] - http://www.perldoc.com/perl5.8.0/pod/func/chmod.html
> 
> 
> The manpage that you refer to explicitly contradicts what you say
> above:
> 
>  $mode = '0644'; chmod $mode, 'foo';      # !!! sets mode to --w----r-T
>  $mode = '0644'; chmod oct($mode), 'foo'; # this is better
>  $mode = 0644;   chmod $mode, 'foo';      # this is best  
> 
> You only need oct() in the second case that you gave.  I mention
> this only in the interest of accuracy, I don't want to start an
> argument.
> 
> Matt.

Whoops, thanks for the correction Matt. I'd meant to include 4 cases:

     1. my $mode = '0644' ; chmod $mode, $file ;   # needs oct()
     2. chmod '0644', $file ;                      # needs oct()
     3. my $mode = 0644 ; chmod $mode, $file ;     # no oct() needed
     4. chmod 0644, $file ;                        # no oct() needed

dbkliv





More information about the Koha-devel mailing list