-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
dircolors: Move the static long string into structures. #5611
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Co-authored-by: Terts Diepraam <[email protected]>
Co-authored-by: Terts Diepraam <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tested in tests/misc/dircolors.pl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reproduce this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be part of this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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