Issue #7373 has been updated by mame (Yusuke Endoh).

Status changed from Assigned to Closed

Applied at r39011.

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Bug #7373: FileUtils#chmod verbose gives error when mode is string
https://bugs.ruby-lang.org/issues/7373#change-35776

Author: asterite (Ary Borenszweig)
Status: Closed
Priority: Normal
Assignee: mame (Yusuke Endoh)
Category: lib
Target version: 2.0.0
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0]


I can see the wrong code in trunk, even though it happened in 1.9.3p194: https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1037 )

asterite @ ~ $ irb
irb(main):001:0> require 'fileutils'
=> true
irb(main):002:0> FileUtils.chmod '+x', 'foo'
=> ["foo"]
irb(main):003:0> FileUtils.chmod '+x', 'foo', verbose: true
ArgumentError: invalid value for Integer(): "+x"
	from /Users/asterite/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:967:in `sprintf'
	from /Users/asterite/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:967:in `chmod'
	from (irb):3
	from /Users/asterite/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'

This is because chmod in verbose mode assumes the mode is a number, and tries to format it in octal:

    fu_output_message sprintf('chmod %o %s', mode, list.join(' ')) if options[:verbose]

The same problem is present in chmod_R.

Sorry I don't include a patch, I'm not sure how to solve it. Maybe check if mode is a number and then use %o, else use %s.


-- 
http://bugs.ruby-lang.org/