develooper Front page | perl.perl5.porters | Postings from September 2016

[perl #129183] perl -S erroneously allows \ escapes in PATH

Thread Next
Father Chrysostomos
September 3, 2016 05:28
[perl #129183] perl -S erroneously allows \ escapes in PATH
Message ID:
# New Ticket Created by  Father Chrysostomos 
# Please include the string:  [perl #129183]
# in the subject line of all future correspondence about this issue. 
# <URL: >

On Unix, entries in PATH are separated by : and may validly contain backslashes.  ‘perl -S’ erroneously 

To demonstrate:

$ mkdir ~/'\'
$ cat > ~/'\'/foo
print "Hahaha!\n";
$ chmod +x ~/'\'/foo
$ PATH=~/'\':$PATH foo
$ PATH=~/'\':$PATH perl -S foo
Can't find foo on PATH.
$ echo $PATH

perl is reading the initial ‘/Users/sprout/\:/usr/bin’ as one PATH entry, which is wrong.

The Perl_find_script function in util.c uses delimcpy to find the colon.  delimcpy allows the terminator to be escaped, which is inappropriate for this call site.


Father Chrysostomos

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About