develooper Front page | perl.perl5.porters | Postings from February 2018

[perl #132866] File::Copy::copy() "works" when given a directory asa from parameter

Thread Previous
From:
James E Keenan via RT
Date:
February 14, 2018 14:36
Subject:
[perl #132866] File::Copy::copy() "works" when given a directory asa from parameter
Message ID:
rt-4.0.24-24380-1518618973-133.132866-15-0@perl.org
On Tue, 13 Feb 2018 23:07:40 GMT, daver@activestate.com wrote:
> This is a bug report for perl from daver@activestate.com,
> generated with the help of perlbug 1.40 running under perl 5.20.3.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> File::Copy::copy() seems to expect that calling
> 
> open $fh, '<', '/dir' or ...
> 
> will fail. However, on HPUX this succeeds and reading from the
> filehandle
> returns a directory listing and some sort of binary data junk.
> 

As far as I can tell from reading "perldoc -f open" and "perldoc perlopentut", what happens when you call "open $fh, '<', 'something'" when 'something' is a directory is pretty much undefined.

Hence, I would expect that when you call "copy $fh", you would get undefined behavior as well.  Moreover, 'perldoc File::Copy' specifically guides you away from attempting to copy from filehandles:

#####
Note that passing in files as handles instead of names may lead to loss of information on some operating systems; it is recommended that you use file names whenever possible.
#####

Thank you very much.
-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=132866

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About