ruby-changes:43439
From: nobu <ko1@a...>
Date: Mon, 27 Jun 2016 16:58:38 +0900 (JST)
Subject: [ruby-changes:43439] nobu:r55513 (trunk): FileUtils#install: symbolic mode
nobu 2016-06-27 16:58:34 +0900 (Mon, 27 Jun 2016) New Revision: 55513 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55513 Log: FileUtils#install: symbolic mode * lib/fileutils.rb (FileUtils#install): accecpt symbolic mode, as well as chmod. Modified files: trunk/ChangeLog trunk/lib/fileutils.rb trunk/lib/un.rb Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 55512) +++ lib/fileutils.rb (revision 55513) @@ -759,7 +759,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L759 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 https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L774 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 https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L812 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? Index: lib/un.rb =================================================================== --- lib/un.rb (revision 55512) +++ lib/un.rb (revision 55513) @@ -196,7 +196,7 @@ end https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L196 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 Index: ChangeLog =================================================================== --- ChangeLog (revision 55512) +++ ChangeLog (revision 55513) @@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Mon Jun 27 16:55:14 2016 Nobuyoshi Nakada <nobu@r...> +Mon Jun 27 16:58:32 2016 Nobuyoshi Nakada <nobu@r...> + + * lib/fileutils.rb (FileUtils#install): accecpt symbolic mode, as + well as chmod. * lib/fileutils.rb (FileUtils#install): add owner and group options. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/