koha-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Koha-devel] chmod


From: dbkliv
Subject: Re: [Koha-devel] chmod
Date: Fri Jul 4 09:26:05 2003
User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0


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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]