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

ls implementation with extras #183

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

ls implementation with extras #183

wants to merge 3 commits into from

Conversation

mike-ward
Copy link
Contributor

Includes most of the usual ls features plus some extras like table format, checksums and icons.

@spytheman
Copy link
Member

(rebased over latest main, to avoid the mkfifo type mismatch error, that was already fixed on main)

@spytheman
Copy link
Member

Hi, sorry for the delay.

I just tried the PR, and got a different output with -l:
image

vs

image

@spytheman
Copy link
Member

spytheman commented Dec 26, 2024

While I do prefer the output of your version, since it is clearer and easier to read to me,
I think that the goal of the project was to emulate the original GNU coreutils as close as possible, including sorting order and result formatting, so that the tools can be tested/compared against each other.

@JalonSolov
Copy link
Contributor

If you wanted to add an option (that wouldn't be tested against the GNU version), to give the nicer output, that's fine. The default using the regular options should match.

@mike-ward
Copy link
Contributor Author

mike-ward commented Dec 27, 2024

makes sense. I'll see what I can do. Also I'm using GNU ls. The ls in Mac is different option-wise and sometimes layout-wise from gls

@mike-ward
Copy link
Contributor Author

Made some changes to allow the format to look more like GNU. However, there are still significant differences.

  • Sorting: the default is to sort by name. Not sure why you get a different result in testing. I can repro here.
  • Block size is a rabbit hole I'm not willing to go down. Its implementation varies depending on the system your on.

If your goal is parity with GNU then this pull request is likely not going to work.

No hard feelings. It was fun to write.

@JalonSolov
Copy link
Contributor

GNU ls does case-insensitive sort, while it looked like yours did case-sensitive. That was the main difference in the sort of the files/dirs.

The only other difference was the total blocks line at the top of the GNU version, while yours has (much nicer!) separation of dirs vs files, and total file sizes.

Probably the main thing about these tools... the main reason for doing them... is to be able to use them as "drop-in" replacements for the GNU versions. At least by default, or when using the same options as the GNU tools. Extra options are fine (far as I'm concerned). They just need to look/act the same as much as possible when not using extra options.

@mike-ward
Copy link
Contributor Author

mike-ward commented Dec 30, 2024

GNU gls appears to be case sensitive on the Mac.
image

@JalonSolov
Copy link
Contributor

JalonSolov commented Dec 30, 2024

ls from GNU coreutils on Linux sorts case-insensitive.

$ ls --version
ls (GNU coreutils) 9.5
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Richard M. Stallman and David MacKenzie.
$ ls -l
total 18980
drwxr-xr-x  4 jalon jalon    4096 Sep 26 15:55 bench
drwxr-xr-x  2 jalon jalon    4096 Jun 29  2024 bin
-rw-r--r--  1 jalon jalon  196266 Dec 22 09:52 CHANGELOG.md
drwxr-xr-x  2 jalon jalon    4096 Mar 25  2024 changelogs0.x
drwxr-xr-x  3 jalon jalon    4096 Dec 19 07:56 ci
drwxr-xr-x  5 jalon jalon    4096 Nov 22  2023 cmd
-rw-r--r--  1 jalon jalon      44 Jul 18  2021 CODE_OF_CONDUCT.md
-rw-r--r--  1 jalon jalon   17164 Nov 18 16:31 CONTRIBUTING.md
drwxr-xr-x  3 jalon jalon    4096 Dec 30 09:38 doc
-rw-r--r--  1 jalon jalon     674 Nov 18 16:31 Dockerfile
-rw-r--r--  1 jalon jalon    1754 May 27  2024 Dockerfile.alpine
-rw-r--r--  1 jalon jalon     234 Nov  7  2023 Dockerfile.cross
drwxr-xr-x 60 jalon jalon    4096 Dec 27 09:25 examples
-rw-r--r--  1 jalon jalon    4710 Nov  7 14:13 GNUmakefile
...

@JalonSolov
Copy link
Contributor

It appears Mac's gls is non-compliant in it's default sorting. :-\

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.

3 participants