summaryrefslogtreecommitdiff
path: root/t/io
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-07-25 22:04:02 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-07-25 22:08:38 -0700
commit42409c4069deb2417b838a49810ecbce306a72b9 (patch)
treea9ec16fa88220ce555c25416613a812ad50c2951 /t/io
parent9a0c99494cbbb7d1253332ab4ce0581e90f707a7 (diff)
downloadperl-42409c4069deb2417b838a49810ecbce306a72b9.tar.gz
Stop truncate(word) from falling back to file name
In commit 5e0adc2d66, which was a bug fix, I made the mistake of checking the truth of the return value of gv_fetchsv, which is called when truncate’s argument is a bareword. This meant that truncate FOO, 0; would truncate the file named FOO if the glob happened to have been deleted.
Diffstat (limited to 't/io')
-rw-r--r--t/io/fs.t12
1 files changed, 10 insertions, 2 deletions
diff --git a/t/io/fs.t b/t/io/fs.t
index 1cdddec9a3..26208c1c9d 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -46,7 +46,7 @@ $needs_fh_reopen = 1 if (defined &Win32::IsWin95 && Win32::IsWin95());
my $skip_mode_checks =
$^O eq 'cygwin' && $ENV{CYGWIN} !~ /ntsec/;
-plan tests => 51;
+plan tests => 52;
my $tmpdir = tempfile();
my $tmpdir1 = tempfile();
@@ -372,7 +372,7 @@ SKIP: {
SKIP: {
if ($^O eq 'vos') {
- skip ("# TODO - hit VOS bug posix-973 - cannot resize an open file below the current file pos.", 5);
+ skip ("# TODO - hit VOS bug posix-973 - cannot resize an open file below the current file pos.", 6);
}
is(-s $tmpfile, 200, "fh resize to 200 working (filename check)");
@@ -407,6 +407,14 @@ SKIP: {
is(-s $tmpfile, 100, "fh resize by IO slot working");
close FH;
+
+ my $n = "for_fs_dot_t$$";
+ open FH, ">$n" or die "open $n: $!";
+ print FH "bloh blah bla\n";
+ close FH or die "close $n: $!";
+ eval "truncate $n, 0; 1" or die;
+ ok !-z $n, 'truncate(word) does not fall back to file name';
+ unlink $n;
}
}