Cwd::realpath

There are different results between systems that may or may not be
intended (found while chasing a bug in the new PAR::Dist release which
appaarently was only tested on systems that behave like Linux):

--8<---------------cut here---------------start------------->8---
Linux$ perl -MCwd -E 'say Cwd::realpath( "/tmp/does-not-exist" )//"undef", " : $!"'
/tmp/does-not-exist : 
Linux$ perl -MCwd -E 'say Cwd::realpath( "/tmp/does-not-exist/" )//"undef", " : $!"'
undef : No such file or directory
--8<---------------cut here---------------end--------------->8---

Cygwin for instance will instead give this:

--8<---------------cut here---------------start------------->8---
Cygwin$ perl -MCwd -E 'say Cwd::realpath( "/tmp/does-not-exist" )//"undef", " : $!"'
undef : No such file or directory
Cygwin$ perl -MCwd -E 'say Cwd::realpath( "/tmp/does-not-exist/" )//"undef", " : $!"'
undef : No such file or directory
--8<---------------cut here---------------end--------------->8---

I'm not really sure why Linux behaves the way it does, but it seems to
make use of the GNU realpath extension of allowing a non-existing file
component as long as the prefix is fully traversable.  Cygwin should end
up using fast_abs_path, which bails at the start when pointed at
something non-existing:

--8<---------------cut here---------------start------------->8---
    unless (-e $path) {
	require Errno;
	$! = Errno::ENOENT();
	return undef;
    }
--8<---------------cut here---------------end--------------->8---

To me it seems like these differences should be resolved one way or the
other; i.e. either generally allowing a non-existing filename after a
resolved prefix or not allowing it at all.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for KORG EX-800 and Poly-800MkII V0.9:
http://Synth.Stromeko.net/Downloads.html#KorgSDada
0
Stromeko
11/21/2020 5:08:31 PM
perl.perl5.porters 48253 articles. 1 followers. Follow

0 Replies
0 Views

Similar Articles

[PageSpeed] 30

Reply: