Bug #7373
closedFileUtils#chmod verbose gives error when mode is string
Description
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 `'
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.