diff options
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | lib/fileutils.rb | 22 |
2 files changed, 19 insertions, 8 deletions
@@ -1,3 +1,8 @@ +Thu Oct 22 17:57:53 2009 Akinori MUSHA <knu@iDaemons.org> + + * lib/fileutils.rb (FileUtils#fu_get_uid, fu_get_gid): Do not + convert an integer back and forth. + Thu Oct 22 17:29:51 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> * parse.y (arg_prepend): removed. a patch from Mikhail T. in diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 35ca983bcf..5e5066ee3a 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -975,20 +975,26 @@ module FileUtils def fu_get_uid(user) #:nodoc: return nil unless user - user = user.to_s - if /\A\d+\z/ =~ user - then user.to_i - else Etc.getpwnam(user).uid + case user + when Integer + user + when /\A\d+\z/ + user.to_i + else + Etc.getpwnam(user).uid end end private_module_function :fu_get_uid def fu_get_gid(group) #:nodoc: return nil unless group - group = group.to_s - if /\A\d+\z/ =~ group - then group.to_i - else Etc.getgrnam(group).gid + case group + when Integer + group + when /\A\d+\z/ + group.to_i + else + Etc.getgrnam(group).gid end end private_module_function :fu_get_gid |
