Project

General

Profile

Bug #10294

Dir[] cannot be called with an array argument

Added by jacknagel (Jack Nagel) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 2.2.0dev (2014-09-20 trunk 47651) [x86_64-darwin13]
[ruby-core:65265]

Description

The documentation for Dir[] claims that it can be called with an array and it will behave like Dir.glob:

Dir[ array ] → array
Dir[ string [, string ...] ] → array
Equivalent to calling Dir.glob(array,0) and Dir.glob([string,...],0).

However, doing so raises a TypeError:

$ ruby -e "puts Dir[['/bin/bash']]"
-e:1:in `[]': no implicit conversion of Array into String (TypeError)
    from -e:1:in `<main>'

Dir.glob works as documented:

$ ruby -e "puts Dir.glob ['/bin/bash']"
/bin/bash

I'm unsure if this is supposed to work as described or if it is a documentation bug, but it is reproducible on 2.0, 2.1, and trunk.

Associated revisions

Revision abafe335
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

dir.c: fix rdoc [ci skip]

  • dir.c (dir_s_aref): fix rdoc. Dir.glob allows an array but Dir[] not. the former accepts an optional parameter flags, while the latter accepts arbitrary number of arguments but no flags. [ruby-core:65265] [Bug #10294]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 47850
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

dir.c: fix rdoc [ci skip]

  • dir.c (dir_s_aref): fix rdoc. Dir.glob allows an array but Dir[] not. the former accepts an optional parameter flags, while the latter accepts arbitrary number of arguments but no flags. [ruby-core:65265] [Bug #10294]

Revision 47850
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

dir.c: fix rdoc [ci skip]

  • dir.c (dir_s_aref): fix rdoc. Dir.glob allows an array but Dir[] not. the former accepts an optional parameter flags, while the latter accepts arbitrary number of arguments but no flags. [ruby-core:65265] [Bug #10294]

Revision 47850
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

dir.c: fix rdoc [ci skip]

  • dir.c (dir_s_aref): fix rdoc. Dir.glob allows an array but Dir[] not. the former accepts an optional parameter flags, while the latter accepts arbitrary number of arguments but no flags. [ruby-core:65265] [Bug #10294]

Revision 47850
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

dir.c: fix rdoc [ci skip]

  • dir.c (dir_s_aref): fix rdoc. Dir.glob allows an array but Dir[] not. the former accepts an optional parameter flags, while the latter accepts arbitrary number of arguments but no flags. [ruby-core:65265] [Bug #10294]

Revision 47850
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

dir.c: fix rdoc [ci skip]

  • dir.c (dir_s_aref): fix rdoc. Dir.glob allows an array but Dir[] not. the former accepts an optional parameter flags, while the latter accepts arbitrary number of arguments but no flags. [ruby-core:65265] [Bug #10294]

Revision 47850
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

dir.c: fix rdoc [ci skip]

  • dir.c (dir_s_aref): fix rdoc. Dir.glob allows an array but Dir[] not. the former accepts an optional parameter flags, while the latter accepts arbitrary number of arguments but no flags. [ruby-core:65265] [Bug #10294]

Revision f173b876
Added by usa (Usaku NAKAMURA) almost 5 years ago

merge revision(s) 47850: [Backport #10294]

    * dir.c (dir_s_aref): fix rdoc.  `Dir.glob` allows an array but
      `Dir[]` not.  the former accepts an optional parameter `flags`,
      while the latter accepts arbitrary number of arguments but no
      `flags`.  [ruby-core:65265] [Bug #10294]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@47934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 47934
Added by usa (Usaku NAKAMURA) almost 5 years ago

merge revision(s) 47850: [Backport #10294]

* dir.c (dir_s_aref): fix rdoc.  `Dir.glob` allows an array but
  `Dir[]` not.  the former accepts an optional parameter `flags`,
  while the latter accepts arbitrary number of arguments but no
  `flags`.  [ruby-core:65265] [Bug #10294]

Revision 7ec073a8
Added by nagachika (Tomoyuki Chikanaga) almost 5 years ago

merge revision(s) r47850: [Backport #10294]

    * dir.c (dir_s_aref): fix rdoc.  `Dir.glob` allows an array but
      `Dir[]` not.  the former accepts an optional parameter `flags`,
      while the latter accepts arbitrary number of arguments but no
      `flags`.  [ruby-core:65265] [Bug #10294]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 47946
Added by nagachika (Tomoyuki Chikanaga) almost 5 years ago

merge revision(s) r47850: [Backport #10294]

* dir.c (dir_s_aref): fix rdoc.  `Dir.glob` allows an array but
  `Dir[]` not.  the former accepts an optional parameter `flags`,
  while the latter accepts arbitrary number of arguments but no
  `flags`.  [ruby-core:65265] [Bug #10294]

History

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

  • Status changed from Open to Rejected

Not an array of path names, any number of path names,

Dir['/bin/bash', '/bin/sh']

Updated by jacknagel (Jack Nagel) almost 5 years ago

I'm aware of what actually works in practice, but the documentation claims both forms are acceptable:

Dir[ array ] → array
Dir[ string [, string ...] ] → array

https://github.com/ruby/ruby/blob/2a8989d71c611884631c4d9ff5dba65aed00cc83/dir.c#L1871-L1877

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

  • Category set to doc
  • Status changed from Rejected to Open
  • Target version set to 2.2.0
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r47850.


dir.c: fix rdoc [ci skip]

  • dir.c (dir_s_aref): fix rdoc. Dir.glob allows an array but Dir[] not. the former accepts an optional parameter flags, while the latter accepts arbitrary number of arguments but no flags. [ruby-core:65265] [Bug #10294]

Updated by usa (Usaku NAKAMURA) almost 5 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: DONE, 2.1: REQUIRED

Backported into ruby_2_0_0 at r47934.

Updated by nagachika (Tomoyuki Chikanaga) almost 5 years ago

  • Backport changed from 2.0.0: DONE, 2.1: REQUIRED to 2.0.0: DONE, 2.1: DONE

Backported into ruby_2_1 at r47946.

Also available in: Atom PDF