Skip to content

ls: [bugfix] Fixed formatting/padding of question mark inodes#2702

Closed
mtsoltan wants to merge 6 commits intouutils:mainfrom
mtsoltan:master
Closed

ls: [bugfix] Fixed formatting/padding of question mark inodes#2702
mtsoltan wants to merge 6 commits intouutils:mainfrom
mtsoltan:master

Conversation

@mtsoltan
Copy link
Contributor

@mtsoltan mtsoltan commented Oct 2, 2021

Previous behavior: Question mark inodes (for non-existent symlinks) used to cause the item to be unaligned to the column, as the question marks don't take any padding ->

28049410 bin     1966081 home       28049414 lib32              5 m           23 rootfs.img        12 swapfile  ? vmlinuz
16908289 boot      17289 hugepages  28049415 lib64       11665409 mnt          2 run                1 sys       ? vmlinuz.old
 1703937 cdrom  ? initrd.img        28049417 libx32      16515073 opt   28049419 sbin        21757953 tmp              5 x
       2 dev    ? initrd.img.old          11 lost+found         1 proc   1048577 snap        28049409 usr              5 y
24117249 etc    28049413 lib        22806529 media        9961473 root   9306113 srv         20578305 var              5 z

Expected behavior: Item names align, and the question marks pad to the right to be in line with the least significant digit of other inodes in the same column ->

/usr/bin/ls: cannot access '/initrd.img.old': No such file or directory
/usr/bin/ls: cannot access '/vmlinuz.old': No such file or directory
/usr/bin/ls: cannot access '/initrd.img': No such file or directory
/usr/bin/ls: cannot access '/vmlinuz': No such file or directory
28049410 bin	   17289 hugepages	 28049417 libx32             1 proc	    9306113 srv              ? vmlinuz
16908289 boot	       ? initrd.img	       11 lost+found   9961473 root	         12 swapfile         ? vmlinuz.old
 1703937 cdrom	       ? initrd.img.old  22806529 media             23 rootfs.img         1 sys              5 x
       2 dev	28049413 lib		        5 m 	             2 run	   21757953 tmp              5 y
24117249 etc	28049414 lib32		 11665409 mnt	      28049419 sbin	   28049409 usr              5 z
 1966081 home	28049415 lib64		 16515073 opt	       1048577 snap	   20578305 var

Behavior after this pull request: The errors are not displayed (this is explained in a pre-existing comment in test_ls.rs::test_ls_dangling_symlinks()), but the padding of the question-mark is fixed ->

28049410 bin       17289 hugepages       28049417 libx32             1 proc         9306113 srv              ? vmlinuz
16908289 boot          ? initrd.img            11 lost+found   9961473 root              12 swapfile         ? vmlinuz.old
 1703937 cdrom         ? initrd.img.old  22806529 media             23 rootfs.img         1 sys              5 x
       2 dev    28049413 lib                    5 m                  2 run         21757953 tmp              5 y
24117249 etc    28049414 lib32           11665409 mnt         28049419 sbin        28049409 usr              5 z
 1966081 home   28049415 lib64           16515073 opt          1048577 snap        20578305 var     

…perly.

Explicitly put :>8 to right-format inodes, and never left-format them
(in case of a question-mark for example).
…the question-mark.

This is to make sure the behavior does not regress.
@mtsoltan
Copy link
Contributor Author

mtsoltan commented Oct 3, 2021

Interestingly enough, it fails to pass the test I created for it in windows. I'll cross-compile it to windows and test it on my windows machine tomorrow.

@tertsdiepraam
Copy link
Collaborator

Great work! A possible solution to the windows tests might be to pass an explicit width parameter to the command, because it looks like it is putting everything in one column. This is not because of your PR but because of the terminal size the CI uses. Something like this might fix it:

scene
    .ucmd()
    .arg("-Li")
    .arg("temp_dir")
    .arg("-w40")
    .succeeds()
    .stdout_contains(if cfg!(windows) {
        " dangle"
    } else {
        "      ? dangle"
    });

@kimono-koans
Copy link
Contributor

Behavior after this pull request: The errors are not displayed (this is explained in a pre-existing comment in test_ls.rs::test_ls_dangling_symlinks()), but the padding of the question-mark is fixed ->

I'm working on the ls error behavior right now. I'll take a look at this.

@tertsdiepraam
Copy link
Collaborator

This PR has been overtaken by #2809. Thanks for your work on this! Sorry it didn't make it in.

@mtsoltan
Copy link
Contributor Author

Thank you for finishing it! I'm really sorry I couldn't finish it myself. It's like reserving the cookie jar then leaving the cookies to rot :(

I'll get back to contributing to this repository once I have more time on my hands. :3

Have a good time!

@tertsdiepraam
Copy link
Collaborator

No problem! Looking forward to more of your contribution in the future!

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