dircolors: Move the static long string into structures. #5611
dircolors: Move the static long string into structures. #5611sylvestre merged 13 commits intouutils:mainfrom sylvestre:dirdb
Conversation
| OutputFmt::Shell => "LS_COLORS='".to_string(), | ||
| OutputFmt::CShell => "setenv LS_COLORS '".to_string(), | ||
| OutputFmt::Display => String::new(), | ||
| OutputFmt::Unknown => unreachable!(), |
There was a problem hiding this comment.
We should open an issue after this PR to make OutputFmt an Option<OutputFmt> in dircolors so that this case can be eliminated.
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
tertsdiepraam
left a comment
There was a problem hiding this comment.
Final comments otherwise seems ready!
| #[test] | ||
| fn test_print_ls_colors() { | ||
| new_ucmd!() | ||
| .pipe_in("OWT 40;33\n") | ||
| .args(&["--print-ls-colors"]) | ||
| .succeeds() | ||
| .stdout_is("\x1B[40;33mtw\t40;33\x1B[0m\n") | ||
| .no_stderr(); | ||
| } | ||
| */ |
There was a problem hiding this comment.
What's going on here? I'm not able to reproduce what this is supposed to do with GNU I think.
There was a problem hiding this comment.
This is tested in tests/misc/dircolors.pl
There was a problem hiding this comment.
Hmm alright, I still haven't quite figured out how to reproduce it, but I've found the test
There was a problem hiding this comment.
reproduce this test?
There was a problem hiding this comment.
Yeah I've been trying some commands with GNU dircolors to see how this is supposed to work, but it doesn't work for me. It seems to ignore whatever I pipe into it.
| /* | ||
| // Check if data is being piped into the program | ||
| if std::io::stdin().is_terminal() { | ||
| // No data piped, use default behavior | ||
| println!("{}", generate_ls_colors(&out_format, ":")); | ||
| return Ok(()); | ||
| } else { | ||
| // Data is piped, process the input from stdin | ||
| let fin = BufReader::new(std::io::stdin()); | ||
| result = parse(fin.lines().map_while(Result::ok), &out_format, "-"); | ||
| } | ||
| */ |
There was a problem hiding this comment.
Should this be part of this PR?
There was a problem hiding this comment.
maybe ? :)
I am planning to work on this for tests/misc/dircolors.pl next
This to be used in ls
and to simplify the code
AFAIK, it should not fix any gnu issue