FileUtils::chmod - allow symbolic mode
I request that FileUtils::chmod() and FileUtils::chmod_R() accept
symbolic modes, which are strings like "u+x,g-w,o=" (see "symbolic
man chmod for details), in addition to the numeric modes
they currently accept.
If my request is fulfilled, the following would be equivalent:
In addition, symbolic modes would allow delta/patch changes:
This is not so easy with numeric modes, because you must
first read the current mode, apply your delta/patch mode
using a bitwise OR operation, and finally apply the new
numeric mode using FileUtils::chmod().
Thanks for your consideration.
Updated by sunaku (Suraj Kurapati) over 10 years ago
Thanks for your patch, takkanm! I hope the Ruby developers will
accept it into Ruby trunk. I have one small suggestion for you:
def fu_mode(mode, path)
- mode.class == String ? symbolic_modes_to_i(mode, path) : mode
- mode.is_a?(String) ? symbolic_modes_to_i(mode, path) : mode end
Updated by dolzenko (Evgeniy Dolzhenko) almost 10 years ago
+1 Would like to see this it's way to the core, except that
current_file_mode function doesn't seem to be really used anyway and can be removed:
- def symbolic_modes_to_i(modes, path)
- current_mode = current_file_mode(path)
- current_mode = (File.stat(path).mode & 07777) ... =end