From: Gurusamy Sarathy Date: Sun, 20 Feb 2000 17:50:38 +0000 (+0000) Subject: default mkdir() mode argument to 0777 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5a211162cd360449f2dbfb7ca9231c025909353f;p=p5sagit%2Fp5-mst-13.2.git default mkdir() mode argument to 0777 p4raw-id: //depot/perl@5164 --- diff --git a/opcode.h b/opcode.h index 51c2d11..ce88940 100644 --- a/opcode.h +++ b/opcode.h @@ -1725,7 +1725,7 @@ EXT U32 PL_opargs[] = { 0x0002291c, /* link */ 0x0002291c, /* symlink */ 0x0001368c, /* readlink */ - 0x0002291c, /* mkdir */ + 0x0012291c, /* mkdir */ 0x0001379c, /* rmdir */ 0x0002c814, /* open_dir */ 0x0000d600, /* readdir */ diff --git a/opcode.pl b/opcode.pl index abf59a4..59b039b 100755 --- a/opcode.pl +++ b/opcode.pl @@ -709,7 +709,7 @@ rename rename ck_fun isT@ S S link link ck_fun isT@ S S symlink symlink ck_fun isT@ S S readlink readlink ck_fun stu% S? -mkdir mkdir ck_fun isT@ S S +mkdir mkdir ck_fun isT@ S S? rmdir rmdir ck_fun isTu% S? # Directory calls. diff --git a/pod/perldiag.pod b/pod/perldiag.pod index d87d085..d660f94 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1188,7 +1188,7 @@ If you need to represent those character sequences inside a regular expression character class, just quote the square brackets with the backslash: "\[=" and "=\]". -=item chmod: mode argument is missing initial 0 +=item chmod() mode argument is missing initial 0 (W) A novice will sometimes say diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 6b47fc7..5de9dc7 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2417,9 +2417,12 @@ the original list for which the BLOCK or EXPR evaluates to true. =item mkdir FILENAME,MASK +=item mkdir FILENAME + Creates the directory specified by FILENAME, with permissions specified by MASK (as modified by C). If it succeeds it returns true, otherwise it returns false and sets C<$!> (errno). +If omitted, MASK defaults to 0777. In general, it is better to create directories with permissive MASK, and let the user modify that with their C, than it is to supply diff --git a/pp_sys.c b/pp_sys.c index 8cba2ed..f9db38e 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -3376,12 +3376,19 @@ S_dooneliner(pTHX_ char *cmd, char *filename) PP(pp_mkdir) { djSP; dTARGET; - int mode = POPi; + int mode; #ifndef HAS_MKDIR int oldumask; #endif STRLEN n_a; - char *tmps = SvPV(TOPs, n_a); + char *tmps; + + if (MAXARG > 1) + mode = POPi; + else + mode = 0777; + + tmps = SvPV(TOPs, n_a); TAINT_PROPER("mkdir"); #ifdef HAS_MKDIR diff --git a/t/op/mkdir.t b/t/op/mkdir.t index e946023..cf8e55d 100755 --- a/t/op/mkdir.t +++ b/t/op/mkdir.t @@ -1,18 +1,15 @@ #!./perl -# $RCSfile: mkdir.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:06 $ +print "1..9\n"; -print "1..7\n"; - -if ($^O eq 'VMS') { # May as well test the library too - unshift @INC, '../lib'; - require File::Path; - File::Path::rmtree('blurfl'); -} -else { - $^O eq 'MSWin32' ? `del /s /q blurfl 2>&1` : `rm -rf blurfl`; +BEGIN { + chdir 't' if -d 't'; + unshift @INC, '../lib'; } +use File::Path; +rmtree('blurfl'); + # tests 3 and 7 rather naughtily expect English error messages $ENV{'LC_ALL'} = 'C'; $ENV{LANGUAGE} = 'C'; # GNU locale extension @@ -24,3 +21,5 @@ print (-d 'blurfl' ? "ok 4\n" : "not ok 4\n"); print (rmdir('blurfl') ? "ok 5\n" : "not ok 5\n"); print (rmdir('blurfl') ? "not ok 6\n" : "ok 6\n"); print ($! =~ /cannot find|such|exist|not found/i ? "ok 7\n" : "# $!\nnot ok 7\n"); +print (mkdir('blurfl') ? "ok 8\n" : "not ok 8\n"); +print (rmdir('blurfl') ? "ok 9\n" : "not ok 9\n"); diff --git a/toke.c b/toke.c index df9d6a1..6000aba 100644 --- a/toke.c +++ b/toke.c @@ -3955,7 +3955,7 @@ Perl_yylex(pTHX) for (d = s; d < PL_bufend && (isSPACE(*d) || *d == '('); d++) ; if (*d != '0' && isDIGIT(*d)) Perl_warner(aTHX_ WARN_OCTAL, - "chmod: mode argument is missing initial 0"); + "chmod() mode argument is missing initial 0"); } LOP(OP_CHMOD,XTERM);