From 32e547954fbbcbdd6f4468bf3be9e7eaa5d32f0f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sat, 30 Nov 2019 17:58:39 +0900 Subject: [PATCH] Revert "[ruby/fileutils] Fix #install with "X" mode option" This reverts commit eab88d20eaa925d5e61a2a65820a099b46ccf3f8. The some CI was broken with this. --- lib/fileutils.rb | 9 ++++++--- test/fileutils/test_fileutils.rb | 2 -- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 45ec148bb9..59fc8bbb44 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -917,8 +917,11 @@ module FileUtils private_module_function :apply_mask def symbolic_modes_to_i(mode_sym, path) #:nodoc: - path = File.stat(path) unless File::Stat === path - mode = path.mode + mode = if File::Stat === path + path.mode + else + File.stat(path).mode + end mode_sym.split(/,/).inject(mode & 07777) do |current_mode, clause| target, *actions = clause.split(/([=+-])/) raise ArgumentError, "invalid file mode: #{mode_sym}" if actions.empty? @@ -935,7 +938,7 @@ module FileUtils when "x" mask | 0111 when "X" - if path.directory? + if FileTest.directory? path mask | 0111 else mask diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index 82c6389558..ca435ed1ff 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -1182,8 +1182,6 @@ class TestFileUtils < Test::Unit::TestCase assert_filemode 04500, 'tmp/j' install 'tmp/j', 'tmp/k', :mode => "+s" assert_filemode 06500, 'tmp/k' - install 'tmp/a', 'tmp/l', :mode => "o+X" - assert_filemode 0644, 'tmp/l' end if have_file_perm? def test_chmod