Project

General

Profile

Actions

Feature #21872

closed

`-S` with directory separator

Feature #21872: `-S` with directory separator

Added by nobu (Nobuyoshi Nakada) 15 days ago. Updated 13 days ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:124731]

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
Actions

Also available in: PDF Atom