ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:124731] [Ruby Misc#21872] `-S` with directory separator
@ 2026-02-09  9:41 nobu (Nobuyoshi Nakada) via ruby-core
  2026-02-10 10:06 ` [ruby-core:124758] [Ruby Feature#21872] " nobu (Nobuyoshi Nakada) via ruby-core
  0 siblings, 1 reply; 2+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2026-02-09  9:41 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ruby-core:124758] [Ruby Feature#21872] `-S` with directory separator
  2026-02-09  9:41 [ruby-core:124731] [Ruby Misc#21872] `-S` with directory separator nobu (Nobuyoshi Nakada) via ruby-core
@ 2026-02-10 10:06 ` nobu (Nobuyoshi Nakada) via ruby-core
  0 siblings, 0 replies; 2+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2026-02-10 10:06 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #21872 has been updated by nobu (Nobuyoshi Nakada).

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.

----------------------------------------
Feature #21872: `-S` with directory separator
https://bugs.ruby-lang.org/issues/21872#change-116364

* 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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-10 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-09  9:41 [ruby-core:124731] [Ruby Misc#21872] `-S` with directory separator nobu (Nobuyoshi Nakada) via ruby-core
2026-02-10 10:06 ` [ruby-core:124758] [Ruby Feature#21872] " nobu (Nobuyoshi Nakada) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).