Actions
Feature #21872
closed`-S` with directory separator
Feature #21872:
`-S` with directory separator
Status:
Closed
Assignee:
-
Target version:
-
Description
Ruby’s -S option searches the script from $RUBYPATH and $PATH always:
$ mkdir -p a/test
$ echo 'p $0' > a/test/t.rb
$ chmod +x a/test/t.rb
$ PATH=$PWD/a:$PATH ruby -S test/t.rb
However, I don't think this action is intentional, because Perl’s -S doesn't search $PATH as stated at https://perldoc.perl.org/perlrun#-S:
makes Perl use the "PATH" environment variable to search for the program unless the name of the program contains path separators.
$ mkdir -p a/test
$ echo 'print $0, "\n"' > a/test/t.pl
$ chmod +x a/test/t.pl
$ PATH=$PWD/a:$PATH perl -S test/t.pl
Can't open perl script "test/t.pl": No such file or directory
This is same in sh:
$ echo 'echo $0' > a/test/t.sh
$ chmod +x a/test/t.sh
$ PATH=$PWD/a:$PATH sh -c test/t.sh
sh: test/t.sh: No such file or directory
Updated by nobu (Nobuyoshi Nakada) 13 days ago
- Tracker changed from Misc to Feature
Matz thinks old Perl didn't see the separator and it changed then probably because of security improvements.
We agreed that also Ruby should follow it.
Updated by nobu (Nobuyoshi Nakada) 13 days ago
- Status changed from Open to Closed
Applied in changeset git|f486ee340289b779654fe2d6c1de5a348fd76d86.
[Feature #21872] Search script from $PATH only if no separator
Actions