diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-02-10 08:17:06 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-02-10 20:07:47 +0900 |
| commit | f486ee340289b779654fe2d6c1de5a348fd76d86 (patch) | |
| tree | b7b0a6239c1a247abe732b82f76a2740191a8ea6 /ruby.c | |
| parent | 1ea75b711f9c64e32b9bc21047a5c1ce6ac0b9ae (diff) | |
[Feature #21872] Search script from $PATH only if no separator
Diffstat (limited to 'ruby.c')
| -rw-r--r-- | ruby.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -2301,6 +2301,16 @@ process_options_global_setup(const ruby_cmdline_options_t *opt, const rb_iseq_t rb_exec_event_hook_script_compiled(ec, iseq, script); } +static bool +has_dir_sep(const char *path) +{ + if (strchr(path, '/')) return true; +#ifdef _WIN32 + if (strchr(path, '\\')) return true; +#endif + return false; +} + static VALUE process_options(int argc, char **argv, ruby_cmdline_options_t *opt) { @@ -2406,7 +2416,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) if (!opt->script || opt->script[0] == '\0') { opt->script = "-"; } - else if (opt->do_search) { + else if (opt->do_search && !has_dir_sep(opt->script)) { const char *path = getenv("RUBYPATH"); opt->script = 0; |
