1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

ls: implement --color flag

GNU coreutils ls command implements the --color option as follow:
  --color[=WHEN]
          colorize the output; WHEN can be 'always' (default if omitted),
          'auto', or 'never'

With --color=auto, ls emits color codes only when standard output is connected
to a terminal.

Also, add support for the following aliases:
  - ‘always’, ‘yes’, ‘force’
  - ‘never’, ‘no’, ‘none’
  - ‘auto’, ‘tty’, ‘if-tty’

Signed-off-by: Gabriel Ganne <gabriel.ganne@gmail.com>
This commit is contained in:
Gabriel Ganne 2019-06-20 09:55:01 +02:00
parent 33a112d64b
commit edaf2d85cb
2 changed files with 16 additions and 2 deletions

View file

@ -11,3 +11,10 @@ fn test_ls_ls_i() {
new_ucmd!().arg("-i").succeeds();
new_ucmd!().arg("-il").succeeds();
}
#[test]
fn test_ls_ls_color() {
new_ucmd!().arg("--color").succeeds();
new_ucmd!().arg("--color=always").succeeds();
new_ucmd!().arg("--color=never").succeeds();
}