Feature #7288

Documentation missing: FileUtils.chmod "+X", "directory"

Added by Jörg Herzinger over 1 year ago. Updated over 1 year ago.

[ruby-core:48965]
Status:Closed
Priority:Normal
Assignee:Minero Aoki
Category:doc
Target version:2.0.0

Description

Documentation for chmods "X" (uppercase) feature is missing. This sets the execute bit on directories but not on files. Tested on my Ubuntu machine it works although not documented.
Reproducable like this:

[irb]
require 'fileutils'
FileUtils.cd "/tmp";FileUtils.touch "testfile";FileUtils.mkdir "testdir"

FileUtils.chmod "-x", "testfile"; FileUtils.chmod "-x", "testdir"
File.executable? "testdir" => false
File.executable? "testfile" => false

FileUtils.chmod "+X", "testfile"; FileUtils.chmod "+X", "testdir"
File.executable? "testdir" => true
File.executable? "testfile" => false
[/irb]

From chmods man page:
... execute (or search for directories) (x), execute/search only if the file is a directory or already has execute permission for some user (X) ...

Associated revisions

Revision 37652
Added by Zachary Scott over 1 year ago

  • lib/fileutils.rb (chmod): Add "X" to modes, convert format to table [Bug #7288]

History

#1 Updated by Zachary Scott over 1 year ago

  • Category set to doc
  • Target version set to 2.0.0

I was looking through lib/fileutils.rb

It seems it's using the private method symbolicmodestoi which takes the mode passed from FileUtils.chmod and translates it into an octal number, or absolute mode, for use with File.chmod. This then takes us to FileUtils.modemask which does the heavy lifting, and seems to include a special case for "X", which it translates into "0111".

chmod(1): The execute/search bits if the file is a directory or any
of the execute/search bits are set in the original (unmodi-
fied) mode. Operations with the perm symbol X'' are only
meaningful in conjunction with the op symbol
+'', and are
ignored in all other cases.

Call me crazy, but it seems you're right and we need to add this "X" mode to our documentation.

I will try to come up with a patch for this soon.

#2 Updated by Zachary Scott over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37652.
Jörg, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/fileutils.rb (chmod): Add "X" to modes, convert format to table [Bug #7288]

Also available in: Atom PDF