lsd-rs / lsd-rs/lsd

Quoting feature is not fully compatible with GNU ls

Open
#776 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
16.2k
Forks
510
PR merge metrics
No merged PRs in 30d

Description

- os: Fedora Linux 36 (Workstation Edition) x86_64
- `lsd --version`: f5ee0a2b5143b975c277a1c53870c08c6e211c37
- `echo $TERM`: alacritty
- `echo $LS_COLORS`:

## Expected behavior
This issue is a follow up from this issue https://github.com/Peltoche/lsd/issues/660 and the note section in this pr https://github.com/Peltoche/lsd/pull/748.
The following are list of GNU `ls` features that involving quoting that are not implemented in `lsd` yet.
```
$ /usr/bin/ls --version
ls (GNU coreutils) 9.0
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
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.
```
1. List of command line options involving quoting from man page
```
-N, --literal
print entry names without quoting

-Q, --quote-name
enclose entry names in double quotes

--quoting-style=WORD
use quoting style WORD for entry names: literal, locale, shell, shell-always, shell-escape, shell-es‐
cape-always, c, escape (overrides QUOTING_STYLE environment variable)
```
**NOTE**: I didn't investigate each behavior of quoting style yet.

2. GNU `ls` has better file alignment
```
$ /usr/bin/ls -l
total 100
-rw-r--r--. 1 teamrakket teamrakket 0 Nov 19 00:42 'a filename with space'
-rw-r--r--. 1 teamrakket teamrakket 1410 Nov 18 23:55 build.rs
-rw-r--r--. 1 teamrakket teamrakket 30052 Nov 18 23:55 Cargo.lock
-rw-r--r--. 1 teamrakket teamrakket 1449 Nov 18 23:55 Cargo.toml
-rw-r--r--. 1 teamrakket teamrakket 17756 Nov 18 23:55 CHANGELOG.md
drwxr-xr-x. 1 teamrakket teamrakket 96 Oct 16 02:44 ci
-rw-r--r--. 1 teamrakket teamrakket 25 Oct 16 02:44 CODEOWNERS
drwxr-xr-x. 1 teamrakket teamrakket 12 Oct 16 02:44 doc
-rw-r--r--. 1 teamrakket teamrakket 11359 Oct 16 02:44 LICENSE
-rw-r--r--. 1 teamrakket teamrakket 19942 Nov 18 23:55 README.md
-rw-r--r--. 1 teamrakket teamrakket 178 Oct 16 02:46 rustfmt.toml
drwxr-xr-x. 1 teamrakket teamrakket 192 Nov 18 23:55 src
drwxr-xr-x. 1 teamrakket teamrakket 72 Oct 16 02:47 target
drwxr-xr-x. 1 teamrakket teamrakket 0 Nov 19 00:03 test-quote
drwxr-xr-x. 1 teamrakket teamrakket 28 Oct 16 02:46 tests
```
```
$ cargo run -- -l --ignore-config
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `target/debug/lsd -l --ignore-config`
.rw-r--r--. teamrakket teamrakket 0 B Sat Nov 19 00:42:11 2022  'a filename with space'
.rw-r--r--. teamrakket teamrakket 1.4 KB Fri Nov 18 23:55:37 2022  build.rs
.rw-r--r--. teamrakket teamrakket 29 KB Fri Nov 18 23:55:37 2022  Cargo.lock
.rw-r--r--. teamrakket teamrakket 1.4 KB Fri Nov 18 23:55:37 2022  Cargo.toml
.rw-r--r--. teamrakket teamrakket 17 KB Fri Nov 18 23:55:37 2022  CHANGELOG.md
drwxr-xr-x. teamrakket teamrakket 96 B Sun Oct 16 02:44:26 2022  ci
.rw-r--r--. teamrakket teamrakket 25 B Sun Oct 16 02:44:26 2022  CODEOWNERS
drwxr-xr-x. teamrakket teamrakket 12 B Sun Oct 16 02:44:26 2022  doc
.rw-r--r--. teamrakket teamrakket 11 KB Sun Oct 16 02:44:26 2022  LICENSE
.rw-r--r--. teamrakket teamrakket 20 KB Fri Nov 18 23:55:37 2022  README.md
.rw-r--r--. teamrakket teamrakket 178 B Sun Oct 16 02:46:28 2022  rustfmt.toml
drwxr-xr-x. teamrakket teamrakket 192 B Fri Nov 18 23:55:37 2022  src
drwxr-xr-x. teamrakket teamrakket 72 B Sun Oct 16 02:47:08 2022  target
drwxr-xr-x. teamrakket teamrakket 0 B Sat Nov 19 00:03:47 2022  test-quote
drwxr-xr-x. teamrakket teamrakket 28 B Sun Oct 16 02:46:28 2022  tests
```

3. Some character in filename are not get quoted such as `!` or `(`
```
$ /usr/bin/ls
'20 20' 2B+2B 37737 42B42 4DM4D 58X58 63c63 6En6E 79y79 ci
'21!21' 2C,2C 38838 43C43 4EN4E 59Y59 64d64 6Fo6F 7Az7A CODEOWNERS
'22"22' 2D-2D 39939 44D44 4FO4F 5AZ5A 65e65 70p70 7B{7B doc
23#23 2E.2E 3A:3A 45E45 50P50 '5B[5B' 66f66 71q71 '7C|7C' 'filename with $'
'24$24' 30030 '3B;3B' 46F46 51Q51 '5C\5C' 67g67 72r72 7D}7D LICENSE
25%25 31131 '3C<3C' 47G47 52R52 5D]5D 68h68 73s73 7E~7E README.md
'26&26' 32232 '3D=3D' 48H48 53S53 '5E^5E' 69i69 74t74 'a filename with space' rustfmt.toml
"27'27" 33333 '3E>3E' 49I49 54T54 5F_5F 6Aj6A 75u75 build.rs src
'28(28' 34434 '3F?3F' 4AJ4A 55U55 '60`60' 6Bk6B 76v76 Cargo.lock target
'29)29' 35535 40@40 4BK4B 56V56 61a61 6Cl6C 77w77 Cargo.toml test-quote
'2A*2A' 36636 41A41 4CL4C 57W57 62b62 6Dm6D 78x78 CHANGELOG.md tests
```
```
$ cargo run -- --ignore-config
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `target/debug/lsd --ignore-config`
 '20 20'  2D-2D  3B;3B  48H48  55U55  62b62  6Fo6F  7C|7C  README.md
 21!21  2E.2E  3C<3C  49I49  56V56  63c63  70p70  7D}7D  rustfmt.toml
 '22"22'  30030  3D=3D  4AJ4A  57W57  64d64  71q71  7E~7E  src
 23#23  31131  3E>3E  4BK4B  58X58  65e65  72r72  'a filename with space'  target
 '24$24'  32232  3F?3F  4CL4C  59Y59  66f66  73s73  build.rs  test-quote
 25%25  33333  40@40  4DM4D  5AZ5A  67g67  74t74  Cargo.lock  tests
 26&26  34434  41A41  4EN4E  5B[5B  68h68  75u75  Cargo.toml
 "27'27"  35535  42B42  4FO4F  '5C\5C'  69i69  76v76  CHANGELOG.md
 28(28  36636  43C43  50P50  5D]5D  6Aj6A  77w77  ci
 29)29  37737  44D44  51Q51  5E^5E  6Bk6B  78x78  CODEOWNERS
 2A*2A  38838  45E45  52R52  5F_5F  6Cl6C  79y79  doc
 2B+2B  39939  46F46  53S53  60`60  6Dm6D  7Az7A  'filename with $'
 2C,2C  3A:3A  47G47  54T54  61a61  6En6E  7B{7B  LICENSE
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the listed cases on Fedora or another Linux system, comparing `/usr/bin/ls` with `cargo run -- --ignore-config` and `cargo run -- -l --ignore-config`. Review the CLI's existing quoting and column-alignment entry points, then use the GNU `ls` examples as the behavioral reference. Done means the listed quoting options, special-character handling, and long-list alignment match the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.