Skip to content

ls implementation with extras - #183

Open
mike-ward wants to merge 3 commits into
vlang:mainfrom
mike-ward:ls
Open

ls implementation with extras#183
mike-ward wants to merge 3 commits into
vlang:mainfrom
mike-ward:ls

Conversation

@mike-ward

Copy link
Copy Markdown
Contributor

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

@spytheman

Copy link
Copy Markdown
Contributor

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

@spytheman

Copy link
Copy Markdown
Contributor

Hi, sorry for the delay.

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

vs

image

@spytheman

spytheman commented Dec 26, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

mike-ward commented Dec 27, 2024

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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

mike-ward commented Dec 30, 2024

Copy link
Copy Markdown
ContributorAuthor

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

@JalonSolov

JalonSolov commented Dec 30, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@JalonSolov

Copy link
Copy Markdown
Contributor

@mike-ward Any plans to work on this again? If not, would you be open to someone else taking what's here and running with it?

@mike-ward

Copy link
Copy Markdown
ContributorAuthor

I don't mind at all. Have fun with it.

Sign up for freeto 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

@mike-ward@spytheman@JalonSolov