1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2016-06-27 07:58:34 +00:00
parent 10fcca8f15
commit 2a5183c2e4
3 changed files with 13 additions and 5 deletions

View file

@ -1,4 +1,7 @@
Mon Jun 27 16:55:14 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
Mon Jun 27 16:58:32 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/fileutils.rb (FileUtils#install): accecpt symbolic mode, as
well as chmod.
* lib/fileutils.rb (FileUtils#install): add owner and group
options.

View file

@ -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?

View file

@ -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