Fille::stat returns defined on <control> character 0x00 - perl - feature or bug? -
# perl 5, version 22, subversion 1 (v5.22.1) # built x86_64-linux-gnu-thread-multi
use file::stat; $wchar = chr 0; $unicode = sprintf 'u+%06x', ord $wchar; $file = './'.$wchar; $sb = stat($file); if($sb){ printf "file %s, size %s, perm %04o, mtime %s\n", $file, $sb->size, $sb->mode & 07777, scalar localtime $sb->mtime; printf "unicode $unicode\n", }
----- gives me.. ----
file ./^@, size 4096, perm 0775, mtime mon aug 14 20:34:21 2017 unicode u+000000
i'm bit baffled. suggestions why happen. feature or bug?
stat
passes string os untouched. os expects nul-terminated string, sees ./
when pass ./␀
.
before 5.20, used case open
well. returns error enoent
instead.
$ perlbrew use 5.20.0t $ ls -1 $ perl -e'open $fh, ">", "abc\0def" or die $!;' no such file or directory @ -e line 1. $ perlbrew use 5.18.2t $ ls -1 $ perl -e'open $fh, ">", "abc\0def" or die $!;' $ ls -1 abc
i consider lack of consistency bug.
Comments
Post a Comment