aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-27 07:58:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-27 07:58:34 +0000
commit38ceeba52e78ac634f040dcde37c44ce7419fb11 (patch)
treecf32eef678709e05325d41f3ef4515d56c5b0528 /lib
parentfa68e03dbbd82b81e89099daeb0c70020c6be404 (diff)
downloadruby-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')
-rw-r--r--lib/fileutils.rb11
-rw-r--r--lib/un.rb2
2 files changed, 9 insertions, 4 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?
diff --git a/lib/un.rb b/lib/un.rb
index 54abd74060..745afcd958 100644
--- a/lib/un.rb
+++ b/lib/un.rb
@@ -196,7 +196,7 @@ end
def install
setup("pm:o:g:") do |argv, options|
- options[:mode] = (mode = options.delete :m) ? mode.oct : 0755
+ (mode = options.delete :m) and options[:mode] = mode
options[:preserve] = true if options.delete :p
(owner = options.delete :o) and options[:owner] = owner
(group = options.delete :g) and options[:group] = group