Skip to content

Implemented chmod command. Github issue 35#48

Merged
arturadib merged 5 commits intoshelljs:masterfrom
brandonramirez:chmod
Jan 8, 2013
Merged

Implemented chmod command. Github issue 35#48
arturadib merged 5 commits intoshelljs:masterfrom
brandonramirez:chmod

Conversation

@brandonramirez
Copy link
Copy Markdown
Contributor

I have attempted to mimic the behavior of POSIX chmod as much as possible. I used the following resources as references and documented any deviations from the POSIX standard.

http://www.unix.com/tips-tutorials/19060-unix-file-permissions.html (used as a spec for parsing symbolic modes like u+x).
http://www.kernel.org/doc/man-pages/online/pages/man2/chmod.2.html (documented bit positions)
http://linux.die.net/man/1/chmod (functionality and command-line options)

I have included appropriate unit tests and run the code through jshint.

shell.js Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since these are not shared among other functions, can we move all constants to either inside _chmod or inside a global object - say PERMS or something? thanks!

@arturadib
Copy link
Copy Markdown
Collaborator

Superb work Brandon! Have you tested this on Windows? I don't have a VM handy, but I'll try to get one and test it before merging if you haven't already.

@arturadib
Copy link
Copy Markdown
Collaborator

By the way, re:compatibility with Windows, we can only be as compliant as the Node API - it's OK to leave the normalization of platforms upstream

@brandonramirez
Copy link
Copy Markdown
Contributor Author

I have not tested it on Windows. I'm not entirely sure what the correct
behavior even ought to be since chmod technically doesn't apply to Windows.
Cygwin's translation layer somehow maps the POSIX permissions to Windows
NTFS permissions, but I'm not sure if node.js's API does that.

I agree that even if it doesn't work on Windows, we should try to test it
on Windows so that we can document whatever the behavior is.

On Thu, Jan 3, 2013 at 11:00 AM, Artur Adib notifications@github.comwrote:

By the way, re:compatibility with Windows, we can only be as compliant as
the Node API - it's OK to leave the normalization of platforms upstream


Reply to this email directly or view it on GitHubhttps://github.com//pull/48#issuecomment-11848741.

@brandonramirez
Copy link
Copy Markdown
Contributor Author

I agree with the PERM* constants. I wasn't happy about exposing them to the global namespace (well, module global), but didn't feel like spending the time to come up with a better way. I didn't want them to be in the method for encapsulation purposes.

But I should have done better. I will put them into a global CHMOD_PERMS object to at least clean up the namespace. I'll get to that later this evening.

@arturadib
Copy link
Copy Markdown
Collaborator

nice, thanks! all merged

arturadib added a commit that referenced this pull request Jan 8, 2013
Implemented chmod command.  Github issue 35
@arturadib arturadib merged commit 91cb4eb into shelljs:master Jan 8, 2013
@brandonramirez brandonramirez deleted the chmod branch January 18, 2013 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants