diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-27 07:58:34 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-27 07:58:34 +0000 |
commit | 38ceeba52e78ac634f040dcde37c44ce7419fb11 (patch) | |
tree | cf32eef678709e05325d41f3ef4515d56c5b0528 /lib/fileutils.rb | |
parent | fa68e03dbbd82b81e89099daeb0c70020c6be404 (diff) | |
download | ruby-38ceeba52e78ac634f040dcde37c44ce7419fb11.tar.gz |
FileUtils#install: symbolic mode
* lib/fileutils.rb (FileUtils#install): accecpt symbolic mode, as
well as chmod.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r-- | lib/fileutils.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index d5bda95b58..e9e9019a58 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -759,7 +759,7 @@ module FileUtils if verbose msg = +"install -c" msg << ' -p' if preserve - msg << ' -m 0%o' % mode if mode + msg << ' -m ' << mode_to_s(mode) if mode msg << " -o #{owner}" if owner msg << " -g #{group}" if group msg << ' ' << [src,dest].flatten.join(' ') @@ -774,7 +774,7 @@ module FileUtils remove_file d, true copy_file s, d File.utime st.atime, st.mtime, d if preserve - File.chmod mode, d if mode + File.chmod fu_mode(mode, st), d if mode File.chown uid, gid, d if uid or gid end end @@ -812,7 +812,12 @@ module FileUtils private_module_function :apply_mask def symbolic_modes_to_i(mode_sym, path) #:nodoc: - mode_sym.split(/,/).inject(File.stat(path).mode & 07777) do |current_mode, clause| + 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? target = 'a' if target.empty? |