Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request (ls): format file mode (permission) in base 8 #1059

Open
nfischer opened this issue Jan 6, 2022 · 1 comment
Open

Feature request (ls): format file mode (permission) in base 8 #1059

nfischer opened this issue Jan 6, 2022 · 1 comment
Labels
bash compat Compatibility issues with bash or POSIX behavior feature low priority

Comments

@nfischer
Copy link
Member

nfischer commented Jan 6, 2022

I noticed that shx ls -l prints the file permission in base 10 (decimal). This is difficult to understand since this is represented more naturally in base 8 (octal). The ShellJS API (shell.ls('-l')) actually returns a structured object, however it includes a toString() implementation on the object as well:

shelljs/src/ls.js

Lines 136 to 139 in ad91197

stats.toString = function () {
// Return a string resembling unix's `ls -l` format
return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' ');
};

Most folks relying on shell.ls('-l') are probably using the structured object rather than its stringified version. The stringified version is mostly relevant for https://github.com/shelljs/shx and https://github.com/nfischer/n_shell.

@nfischer nfischer added feature low priority bash compat Compatibility issues with bash or POSIX behavior labels Jan 6, 2022
@nfischer
Copy link
Member Author

nfischer commented Jan 6, 2022

We could also consider converting this into the -rw-rw-r-- format instead of octal, but that's a bit more work.


Other discrepancies I noticed:

  • shx ls -l prints a UID (as an integer) instead of the username/groupname
  • shx ls -l outputs timestamps in the format Wed Jan 05 2022 19:05:48 GMT-0800 (Pacific Standard Time) as opposed to the more succinct Jan 5 19:05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bash compat Compatibility issues with bash or POSIX behavior feature low priority
Projects
None yet
Development

No branches or pull requests

1 participant