Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 62377
Status: open
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: EDAVIS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.109
Fixed in: (no value)



Subject: Suggested policy: mkdir(x, 0777) is better as mkdir(x)
In recent (all?) versions of perl, the default permission mask for mkdir() is 0777. But there's a lot of code that says mkdir($dir, 0777) or similar. This would be clearer as just mkdir($dir). A new policy could warn about mkdir with a fixed mask of 0777.
Subject: Re: [rt.cpan.org #62377] Suggested policy: mkdir(x, 0777) is better as mkdir(x)
Date: Fri, 29 Oct 2010 06:22:57 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
I disagree with this. How many people even think about what the mask for mkdir is? Being explicit about it is /more/ clear, not less.
Show quoted text
>How many people even think about what the mask for mkdir is?
Surely not many; everyone just puts in 0777 because that's the odd-looking boilerplate you learn to use. I believe that the best practice is normally to use the 0777 permissions. As perlfaq puts it, Show quoted text
>In general, it is better to create directories with permissive >MASK, and let the user modify that with their "umask", than it >is to supply a restrictive MASK and give the user no way to be >more permissive. The exceptions to this rule are when the file >or directory should be kept private (mail files, for instance).
So, if it's usually what you want, and perl has even made it the default choice, it's probably clearer to use that default choice. I take your point that it would be nice if everyone carefully thought about what permissions they want when creating files or directories. However I don't think that is achieved by the current situation where there is just a weird incantation 0777 that, without much thought, tends to attach itself to mkdir calls. Note that creating a file with open($fh, '>', $filename) will also default to the permissions given by your umask, and that's not considered bad.