From: Rafael Garcia-Suarez Date: Tue, 3 May 2005 12:15:45 +0000 (+0000) Subject: mkdir without arguments now defaults to $_ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=491873e5975978ffc50c5af79581657c3f0e3068;p=p5sagit%2Fp5-mst-13.2.git mkdir without arguments now defaults to $_ p4raw-id: //depot/perl@24378 --- diff --git a/opcode.h b/opcode.h index 8e52cf6..8161c70 100644 --- a/opcode.h +++ b/opcode.h @@ -1767,7 +1767,7 @@ EXT const U32 PL_opargs[] = { 0x0002291c, /* link */ 0x0002291c, /* symlink */ 0x0001368c, /* readlink */ - 0x0012291c, /* mkdir */ + 0x0013299c, /* mkdir */ 0x0001379c, /* rmdir */ 0x0002c814, /* open_dir */ 0x0000d600, /* readdir */ diff --git a/opcode.pl b/opcode.pl index ac9499d..cef6e0c 100755 --- a/opcode.pl +++ b/opcode.pl @@ -834,7 +834,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 isTu@ S? S? rmdir rmdir ck_fun isTu% S? # Directory calls. diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 79ebdf9..81a42c2 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2687,10 +2687,13 @@ and you get list of anonymous hashes each with only 1 entry. =item mkdir FILENAME +=item mkdir + 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. +If omitted, MASK defaults to 0777. If omitted, FILENAME defaults +to C<$_>. 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/t/op/cproto.t b/t/op/cproto.t index 8b6bad1..a50a851 100644 --- a/t/op/cproto.t +++ b/t/op/cproto.t @@ -137,7 +137,7 @@ lstat (*) lt ($$) m undef map undef -mkdir ($;$) +mkdir () msgctl ($$$) msgget ($$) msgrcv ($$$$$) diff --git a/t/op/mkdir.t b/t/op/mkdir.t index 6198000..65a7d3a 100755 --- a/t/op/mkdir.t +++ b/t/op/mkdir.t @@ -1,4 +1,4 @@ -#!./perl +#!./perl -w BEGIN { chdir 't' if -d 't'; @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 13; +plan tests => 22; use File::Path; rmtree('blurfl'); @@ -34,3 +34,21 @@ SKIP: { ok(rmdir('blurfl///')); ok(!-d 'blurfl'); } + +# test default argument + +$_ = 'blurfl'; +ok(mkdir); +ok(-d); +ok(rmdir); +ok(!-d); +$_ = 'lfrulb'; + +{ + my $_ = 'blurfl'; + ok(mkdir); + ok(-d); + ok(-d 'blurfl'); + ok(!-d 'lfrulb'); + ok(rmdir); +}