From: Nobuyoshi Nakada Date: 2011-07-16T19:46:56+09:00 Subject: [ruby-core:38098] Re: [Ruby 1.9 - Bug #4731] ruby -S irb fails with mingw/msys vanilla builds Hi, At Fri, 15 Jul 2011 21:28:50 +0900, Luis Lavena wrote in [ruby-core:38075]: > On RubyInstaller we replaced that with plain stubs and the > original scripts from Ruby's source code, see here: I see. There is only irb.bat, not irb sans the suffix. In that sense, it's natural to fail, but maybe unexpected behavior. Now I'm thinking to make -S option search with .bat (and .cmd too) suffix if it is not found. How do you feel about this? diff --git a/ruby.c b/ruby.c index 93b12d8..b8258ea 100644 --- a/ruby.c +++ b/ruby.c @@ -1288,14 +1288,42 @@ process_options(int argc, char **argv, struct cmdline_options *opt) } else if (opt->do_search) { char *path = getenv("RUBYPATH"); +#ifdef DOSISH + char *batch = NULL; + size_t batchlen = 0; +#endif opt->script = 0; if (path) { opt->script = dln_find_file_r(argv[0], path, fbuf, sizeof(fbuf)); } +#ifdef DOSISH if (!opt->script) { - opt->script = dln_find_file_r(argv[0], getenv(PATH_ENV), fbuf, sizeof(fbuf)); + batchlen = strlen(argv[0]); + batch = ALLOC_N(char, batchlen + 5); + memcpy(batch, argv[0], batchlen); + memcpy(batch + batchlen, ".bat", 5); + opt->script = dln_find_file_r(batch, path, fbuf, sizeof(fbuf)); + if (!opt->script) { + memcpy(batch + batchlen, ".cmd", 5); + opt->script = dln_find_file_r(batch, path, fbuf, sizeof(fbuf)); + } + } +#endif + if (!opt->script && (path = getenv(PATH_ENV)) != NULL) { + opt->script = dln_find_file_r(argv[0], path, fbuf, sizeof(fbuf)); } +#ifdef DOSISH + if (!opt->script) { + memcpy(batch + batchlen, ".bat", 5); + opt->script = dln_find_file_r(batch, path, fbuf, sizeof(fbuf)); + if (!opt->script) { + memcpy(batch + batchlen, ".cmd", 5); + opt->script = dln_find_file_r(batch, path, fbuf, sizeof(fbuf)); + } + } + if (batch) xfree(batch); +#endif if (!opt->script) opt->script = argv[0]; } -- Nobu Nakada