From: "nobu (Nobuyoshi Nakada) via ruby-core" Date: 2026-02-09T09:41:09+00:00 Subject: [ruby-core:124731] [Ruby Misc#21872] `-S` with directory separator Issue #21872 has been reported by nobu (Nobuyoshi Nakada). ---------------------------------------- Misc #21872: `-S` with directory separator https://bugs.ruby-lang.org/issues/21872 * Author: nobu (Nobuyoshi Nakada) * Status: Open ---------------------------------------- Ruby���s `-S` option searches the script from `$RUBYPATH` and `$PATH` always: ```console $ 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**. ```console $ 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`: ```console $ 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 ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/