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: too many totals #359

Merged
merged 1 commit into from
Dec 2, 2023
Merged

ls: too many totals #359

merged 1 commit into from
Dec 2, 2023

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Dec 2, 2023

  • File arguments are split into two lists: Dirs and Files
  • Two separate loops call List(), first for Files list then for Dirs
  • "perl ls -lR a a/a" was printing a "total" line twice, once (correctly) for dir "a" then (incorrectly) for regular file "a/a"
  • Directory name line "a/a:" was also being printed for argument "a/a" but it is not a directory (see below output)
  • Fix this by passing a new param to List() to tell it whether the entry being listed is a directory
%perl ls -lR a a/a # old output
a/a:
total 176
-rwxr-xr-x   1 pi       pi           88214 Nov 21 10:20 a/a

a:
total 224
-rwxr-xr-x   1 pi       pi           88214 Nov 21 10:20 a
drwxr-xr-x   2 pi       pi            4096 Dec  1 19:32 b
-rw-r--r--   1 pi       pi           20480 Nov 20 04:02 new.tar

a/b:
total 8
-rw-r--r--   1 pi       pi               3 Dec  1 19:32 new

* File arguments are split into two lists: Dirs and Files
* Two separate loops call List(), first for Files list then for Dirs
* "perl ls -lR a a/a" was printing a "total" line twice, once (correctly) for dir "a" then (incorrectly) for regular file "a/a"
* Directory name line "a/a:" was also being printed for argument "a/a" but it is not a directory (see below output)
* Fix this by passing a new param to List() to tell it whether the entry being listed is a directory

%perl ls -lR a a/a # old output
a/a:
total 176
-rwxr-xr-x   1 pi       pi           88214 Nov 21 10:20 a/a

a:
total 224
-rwxr-xr-x   1 pi       pi           88214 Nov 21 10:20 a
drwxr-xr-x   2 pi       pi            4096 Dec  1 19:32 b
-rw-r--r--   1 pi       pi           20480 Nov 20 04:02 new.tar

a/b:
total 8
-rw-r--r--   1 pi       pi               3 Dec  1 19:32 new
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: ls The ls program labels Dec 2, 2023
@briandfoy briandfoy self-assigned this Dec 2, 2023
@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Dec 2, 2023
@briandfoy briandfoy merged commit a95471c into briandfoy:master Dec 2, 2023
2 checks passed
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: ls The ls program Status: released there is a new release with this fix Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants