[ruby-cvs:78419] eab88d20ea (master): [ruby/fileutils] Fix #install with "X" mode option

"Nobuyoshi Nakada" <[email protected]>
Newsgroups gmane.comp.lang.ruby.cvs
Message-ID <[email protected]>
Nobuyoshi Nakada	2019-10-03 01:39:02 +0900 (Thu, 03 Oct 2019)

  New Revision: eab88d20ea

  https://github.com/ruby/ruby/commit/eab88d20ea

  Log:
    [ruby/fileutils] Fix #install with "X" mode option
    
    `FileUtils#install` methed raises an unexpected `TypeError`, when
    called with `mode:` option which has `"X"`.
    
    ```
    $ ruby -rfileutils -e 'FileUtils.install("tmp/a", "tmp/b", mode: "o+X")'
    /opt/local/lib/ruby/2.7.0/fileutils.rb:942:in `directory?': no implicit conversion of File::Stat into String (TypeError)
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:942:in `block (3 levels) in symbolic_modes_to_i'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `each_char'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `each'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `inject'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `block (2 levels) in symbolic_modes_to_i'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `each'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `each_slice'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `block in symbolic_modes_to_i'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `each'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `inject'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `symbolic_modes_to_i'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:973:in `fu_mode'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:883:in `block in install'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:1588:in `block in fu_each_src_dest'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:1604:in `fu_each_src_dest0'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:1586:in `fu_each_src_dest'
    from /opt/local/lib/ruby/2.7.0/fileutils.rb:877:in `install'
    from -e:1:in `<main>'
    ```
    
    In spite of that `symbolic_modes_to_i` considers the `File::Stat`
    `path` case at the beginning, in `"X"` case, `path` is passed to
    `FileTest.directory?` method which requires a `String`.  In such
    case, the mode in `path` should be examined instead.
    
    https://github.com/ruby/fileutils/commit/2ea54ade2f

  Modified files:
    lib/fileutils.rb
    test/fileutils/test_fileutils.rb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.