diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bba766070d37ac..c482ad34fb7080 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,6 +15,8 @@ updates: directories: - '/yjit' - '/zjit' + exclude-paths: + - 'gc/mmtk/**' schedule: interval: 'daily' groups: diff --git a/NEWS.md b/NEWS.md index 4f35077bfe0ecf..cdeb44054e1d3f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -66,7 +66,8 @@ releases. * resolv-replace 0.2.0 * syslog 0.4.0 * repl_type_completor 0.1.13 -* rdoc 7.1.0 +* rdoc 7.2.0 +* irb 1.17.0 ### RubyGems and Bundler diff --git a/array.c b/array.c index ac7b73c0dddf49..1b2e395bce1f58 100644 --- a/array.c +++ b/array.c @@ -6747,16 +6747,16 @@ flatten(VALUE ary, int level) * With non-negative integer argument +depth+, flattens recursively through +depth+ levels: * * a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ] - * a # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #] - * a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #] - * a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #] - * a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - * a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] + * a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #] + * a.dup.flatten!(1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #] + * a.dup.flatten!(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #] + * a.dup.flatten!(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #] + * a.dup.flatten!(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #] * * With +nil+ or negative argument +depth+, flattens all levels: * - * a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - * a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] + * a.dup.flatten! # => [0, 1, 2, 3, 4, 5, {foo: 0}, #] + * a.dup.flatten!(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #] * * Related: Array#flatten; * see also {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning]. @@ -6803,17 +6803,17 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary) * With non-negative integer argument +depth+, flattens recursively through +depth+ levels: * * a = [ 0, [ 1, [2, 3], 4 ], 5, {foo: 0}, Set.new([6, 7]) ] - * a # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #] - * a.flatten(0) # => [0, [1, [2, 3], 4], 5, {:foo=>0}, #] - * a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #] - * a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {:foo=>0}, #] - * a.flatten(2) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - * a.flatten(3) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] + * a # => [0, [1, [2, 3], 4], 5, {foo: 0}, #] + * a.flatten(0) # => [0, [1, [2, 3], 4], 5, {foo: 0}, #] + * a.flatten(1 ) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #] + * a.flatten(1.1) # => [0, 1, [2, 3], 4, 5, {foo: 0}, #] + * a.flatten(2) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #] + * a.flatten(3) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #] * * With +nil+ or negative +depth+, flattens all levels. * - * a.flatten # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] - * a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {:foo=>0}, #] + * a.flatten # => [0, 1, 2, 3, 4, 5, {foo: 0}, #] + * a.flatten(-1) # => [0, 1, 2, 3, 4, 5, {foo: 0}, #] * * Related: Array#flatten!; * see also {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting]. diff --git a/doc/contributing/documentation_guide.md b/doc/contributing/documentation_guide.md index 4378e028737a37..51b480103c70ac 100644 --- a/doc/contributing/documentation_guide.md +++ b/doc/contributing/documentation_guide.md @@ -6,8 +6,8 @@ in the Ruby core and in the Ruby standard library. ## Generating documentation -Most Ruby documentation lives in the source files and is written in -[RDoc format](https://ruby.github.io/rdoc/RDoc/MarkupReference.html). +Most Ruby documentation lives in the source files, and is written in RDoc format +(described in the [RDoc Markup Reference]). Some pages live under the `doc` folder and can be written in either `.rdoc` or `.md` format, determined by the file extension. @@ -43,14 +43,12 @@ Use your judgment about what the user needs to know. - Write short declarative or imperative sentences. - Group sentences into (ideally short) paragraphs, each covering a single topic. -- Organize material with - [headings]. -- Refer to authoritative and relevant sources using - [links](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Links). +- Organize material with [headings]. +- Refer to authoritative and relevant sources using [links]. - Use simple verb tenses: simple present, simple past, simple future. - Use simple sentence structure, not compound or complex structure. - Avoid: - - Excessive comma-separated phrases; consider a [list]. + - Excessive comma-separated phrases; consider a [list][lists]. - Idioms and culture-specific references. - Overuse of headings. - Using US-ASCII-incompatible characters in C source files; @@ -105,16 +103,16 @@ involving new files `doc/*.rdoc`: */ ``` -### \RDoc +### RDoc Ruby is documented using RDoc. -For information on \RDoc syntax and features, see the -[RDoc Markup Reference](https://ruby.github.io/rdoc/RDoc/MarkupReference.html). +For information on RDoc syntax and features, +see the [RDoc Markup Reference]. ### Output from `irb` For code examples, consider using interactive Ruby, -[irb](https://ruby-doc.org/stdlib/libdoc/irb/rdoc/IRB.html). +[irb]. For a code example that includes `irb` output, consider aligning `# => ...` in successive lines. @@ -133,16 +131,15 @@ Organize a long discussion for a class or module with [headings]. Do not use formal headings in the documentation for a method or constant. In the rare case where heading-like structures are needed -within the documentation for a method or constant, use -[bold text](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Bold) -as pseudo-headings. +within the documentation for a method or constant, +use [bold text] as pseudo-headings. ### Blank Lines A blank line begins a new paragraph. -A [code block](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Code+Blocks) -or [list] should be preceded by and followed by a blank line. +A [code block][code blocks] +or [list][lists] should be preceded by and followed by a blank line. This is unnecessary for the HTML output, but helps in the `ri` output. ### \Method Names @@ -185,7 +182,7 @@ renders as: > - File.new > - File#read. -In general, \RDoc's auto-linking should not be suppressed. +In general, RDoc's auto-linking should not be suppressed. For example, we should write just plain _Float_ (which is auto-linked): ```rdoc @@ -312,10 +309,9 @@ In particular, avoid building tables with HTML tags Alternatives: -- A {verbatim text block}[https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Verbatim+Text+Blocks], +- A [verbatim text block][verbatim text blocks], using spaces and punctuation to format the text; - note that {text markup}[https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Text+Markup] - will not be honored: + note that [text markup][text markup] will not be honored: - Example {source}[https://github.com/ruby/ruby/blob/34d802f32f00df1ac0220b62f72605827c16bad8/file.c#L6570-L6596]. - Corresponding {output}[rdoc-ref:File@ReadWrite+Mode]. @@ -374,9 +370,9 @@ Guidelines: and a short description. - If the method has aliases, mention them in parentheses before the colon (and do not list the aliases separately). - - Check the rendered documentation to determine whether \RDoc has recognized + - Check the rendered documentation to determine whether RDoc has recognized the method and linked to it; if not, manually insert a - [link](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Links). + [link][links]. - If there are numerous entries, consider grouping them into subsections with headings. - If there are more than a few such subsections, @@ -398,11 +394,11 @@ The general structure of the method documentation should be: ### Calling Sequence (for methods written in C) -For methods written in Ruby, \RDoc documents the calling sequence automatically. +For methods written in Ruby, RDoc documents the calling sequence automatically. -For methods written in C, \RDoc cannot determine what arguments -the method accepts, so those need to be documented using \RDoc directive -[`call-seq:`](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Directives+for+Method+Documentation). +For methods written in C, RDoc cannot determine what arguments +the method accepts, so those need to be documented using RDoc directive +[`call-seq:`][call-seq] For a singleton method, use the form: @@ -577,7 +573,7 @@ argument passed if it is not obvious, not explicitly mentioned in the details, and not implicitly shown in the examples. If there is more than one argument or block argument, use a -[labeled list](https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Labeled+Lists). +[labeled list][lists]. ### Corner Cases and Exceptions @@ -618,6 +614,14 @@ For methods that accept multiple argument types, in some cases it can be useful to document the different argument types separately. It's best to use a separate paragraph for each case you are discussing. -[headings]: https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Headings -[list]: https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Lists -[monofont]: https://ruby.github.io/rdoc/RDoc/MarkupReference.html#class-RDoc::MarkupReference-label-Monofont +[bold text]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#bold +[call-seq]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#directive-for-specifying-rdoc-source-format +[code blocks]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#code-blocks +[headings]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#headings +[irb]: https://ruby.github.io/irb/index.html +[links]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#links +[lists]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#lists +[monofont]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#monofont +[RDoc Markup Reference]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html +[text markup]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#text-markup +[verbatim text blocks]: https://ruby.github.io/rdoc/doc/markup_reference/rdoc_rdoc.html#verbatim-text-blocks diff --git a/doc/jit/yjit.md b/doc/jit/yjit.md index 24aa163e60d299..1928ac301ab946 100644 --- a/doc/jit/yjit.md +++ b/doc/jit/yjit.md @@ -91,7 +91,10 @@ git clone https://github.com/ruby/ruby yjit cd yjit ``` -The YJIT `ruby` binary can be built with either GCC or Clang. It can be built either in dev (debug) mode or in release mode. For maximum performance, compile YJIT in release mode with GCC. More detailed build instructions are provided in the [Ruby README](https://github.com/ruby/ruby#how-to-build). +The YJIT `ruby` binary can be built with either GCC or Clang. +It can be built either in dev (debug) mode or in release mode. +For maximum performance, compile YJIT in release mode with GCC. +See [Building Ruby](rdoc-ref:./contributing/building_ruby_md.html#building-ruby). ```sh # Configure in release mode for maximum performance, build and install diff --git a/gems/bundled_gems b/gems/bundled_gems index 91c5387067c1cc..362669162cac05 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -39,9 +39,9 @@ ostruct 0.6.3 https://github.com/ruby/ostruct pstore 0.2.0 https://github.com/ruby/pstore benchmark 0.5.0 https://github.com/ruby/benchmark logger 1.7.0 https://github.com/ruby/logger -rdoc 7.1.0 https://github.com/ruby/rdoc +rdoc 7.2.0 https://github.com/ruby/rdoc win32ole 1.9.2 https://github.com/ruby/win32ole -irb 1.16.0 https://github.com/ruby/irb +irb 1.17.0 https://github.com/ruby/irb reline 0.6.3 https://github.com/ruby/reline readline 0.0.4 https://github.com/ruby/readline fiddle 1.1.8 https://github.com/ruby/fiddle diff --git a/ruby.c b/ruby.c index cd5c8d1d15d66e..3d53610c2473c9 100644 --- a/ruby.c +++ b/ruby.c @@ -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; diff --git a/spec/ruby/command_line/dash_upper_s_spec.rb b/spec/ruby/command_line/dash_upper_s_spec.rb index 17991503f17390..71c6016659e545 100644 --- a/spec/ruby/command_line/dash_upper_s_spec.rb +++ b/spec/ruby/command_line/dash_upper_s_spec.rb @@ -2,7 +2,8 @@ describe 'The -S command line option' do before :each do - @path = [ENV['PATH'], fixture(__FILE__, "bin")].join(':') + @bin = fixture(__FILE__, "bin") + @path = [ENV['PATH'], @bin].join(File::PATH_SEPARATOR) end platform_is_not :windows do @@ -10,20 +11,57 @@ # and MRI shows warning when including world writable path in ENV['PATH']. # This is why we are using /success$/ matching in the following cases. + it "runs launcher found in RUBYPATH, but only code after the first /\#!.*ruby.*/-ish line in target file" do + result = ruby_exe(nil, options: '-S hybrid_launcher.sh', env: { 'RUBYPATH' => @bin }, args: '2>&1') + result.should =~ /success$/ + end + it "runs launcher found in PATH, but only code after the first /\#!.*ruby.*/-ish line in target file" do result = ruby_exe(nil, options: '-S hybrid_launcher.sh', env: { 'PATH' => @path }, args: '2>&1') result.should =~ /success$/ end + it "runs launcher found in RUBYPATH" do + result = ruby_exe(nil, options: '-S launcher.rb', env: { 'RUBYPATH' => @bin }, args: '2>&1') + result.should =~ /success$/ + end + it "runs launcher found in PATH" do result = ruby_exe(nil, options: '-S launcher.rb', env: { 'PATH' => @path }, args: '2>&1') result.should =~ /success$/ end + it "runs launcher found in RUBYPATH and sets the exit status to 1 if it fails" do + result = ruby_exe(nil, options: '-S dash_s_fail', env: { 'RUBYPATH' => @bin }, args: '2>&1', exit_status: 1) + result.should =~ /\bdie\b/ + $?.exitstatus.should == 1 + end + it "runs launcher found in PATH and sets the exit status to 1 if it fails" do result = ruby_exe(nil, options: '-S dash_s_fail', env: { 'PATH' => @path }, args: '2>&1', exit_status: 1) result.should =~ /\bdie\b/ $?.exitstatus.should == 1 end + + ruby_version_is "4.1" do + describe "if the script name contains separator" do + before(:each) do + @bin = File.dirname(@bin) + @path = [ENV['PATH'], @bin].join(File::PATH_SEPARATOR) + end + + it "does not search launcher in RUBYPATH" do + result = ruby_exe(nil, options: '-S bin/launcher.rb', env: { 'RUBYPATH' => @bin }, args: '2>&1', exit_status: 1) + result.should =~ /LoadError/ + $?.should_not.success? + end + + it "does not search launcher in PATH" do + result = ruby_exe(nil, options: '-S bin/launcher.rb', env: { 'PATH' => @path }, args: '2>&1', exit_status: 1) + result.should =~ /LoadError/ + $?.should_not.success? + end + end + end end end diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 0067a497006199..eed8e97da86cad 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -54,7 +54,7 @@ def test_require_too_long_filename end; begin - assert_in_out_err(["-S", "-w", "foo/" * 1024 + "foo"], "") do |r, e| + assert_in_out_err(["-S", "-w", (["foo"] * 1025).join("_")], "") do |r, e| assert_equal([], r) assert_operator(2, :<=, e.size) assert_match(/warning: openpath: pathname too long \(ignored\)/, e.first) diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index cd2dd5d3ff7412..4a31f91b4a091c 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -446,37 +446,28 @@ def test_rubyopt def test_search rubypath_orig = ENV['RUBYPATH'] path_orig = ENV['PATH'] + libpath = (path_orig if path_orig && RbConfig::CONFIG['LIBPATHENV'] == 'PATH') - Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) {|t| - t.puts "p 1" - t.close - - @verbose = $VERBOSE - $VERBOSE = nil + Dir.mktmpdir("test_ruby_test_rubyoption") do |path| + name = "test_rubyoption.rb" + parent, dir = File.split(path) + File.write("#{path}/#{name}", "p 1") + load_error = %r[#{Regexp.quote dir}/#{Regexp.quote name} \(LoadError\)] - path, name = File.split(t.path) - - ENV['PATH'] = (path_orig && RbConfig::CONFIG['LIBPATHENV'] == 'PATH') ? - [path, path_orig].join(File::PATH_SEPARATOR) : path + ENV['PATH'] = [path, *libpath].join(File::PATH_SEPARATOR) assert_in_out_err(%w(-S) + [name], "", %w(1), []) + ENV['PATH'] = [parent, *libpath].join(File::PATH_SEPARATOR) + assert_in_out_err(%W(-S) + ["#{dir}/#{name}"], "", [], load_error) ENV['PATH'] = path_orig ENV['RUBYPATH'] = path assert_in_out_err(%w(-S) + [name], "", %w(1), []) - } - - ensure - if rubypath_orig + ENV['RUBYPATH'] = parent + assert_in_out_err(%w(-S) + ["#{dir}/#{name}"], "", [], load_error) + ensure ENV['RUBYPATH'] = rubypath_orig - else - ENV.delete('RUBYPATH') - end - if path_orig ENV['PATH'] = path_orig - else - ENV.delete('PATH') end - $VERBOSE = @verbose end def test_shebang