Skip to content

Conversation

willshuttleworth
Copy link
Contributor

fixes for #3860. i added the function combo_to_flags() which takes a combination name as a string and decomposes the combination into the individual settings. this function returns a vec of all the flags that correspond to the combination, which are then appended to the valid_args vec that is used during arg parsing. one of the combinations is not fully complete yet, as it requires functionality in #3859, which i will tackle next.

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

let mut flags: Vec<ArgOptions> = Vec::new();
match combo {
"lcase" | "LCASE" => {
if let Some(flag) = string_to_flag("xcase") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are never supposed to fail right? Maybe we should unwrap them? It's better to know early if it doesn't work. I forget how this worked, but maybe we can use the ArgOptions directly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be done in a more functional style with less repetition:

let flags = ["xcase", ...];
let flags = flags
    .iter()
    .map(|f| {
        ArgOptions::Flags(string_to_flag(f).unwrap())
    })
    .collect();

(or don't unwrap and use filter_map)

This also makes it easier to see what these combo flags map to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely agree that the current way I did this is repetitive. I like the functional approach, I'll change it towards that. Unwrapping should be fine, assuming that every flag in every combination is available on all necessary platforms. Maybe some flags in combinations aren't available on something like macOS? I'll need to investigate further.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there are flags that exist in combinations and aren't present on macOS. olcuc for example. I'm thinking its better to not unwrap and use filter_map because the alternative is having cfg platform directives in both flags.rs and stty.rs for the same flags.

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@willshuttleworth
Copy link
Contributor Author

@tertsdiepraam @cakebaker anything else you'd like me to change?

Copy link

github-actions bot commented Jul 9, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

Comment on lines +918 to +920
"-lcase" | "-LCASE" => {
flags = vec!["-xcase", "-iuclc", "-olcuc"];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be the same flags as for lcase/LCASE? From the help:

[-]lcase      same as xcase iuclc olcuc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with GNU stty, '-lcase'/'-LCASE' yields '-xcase -iuclc -olcuc'

flags = vec!["-parenb", "cs8"];
}
"litout" => {
flags = vec!["-parenb", "-istrip", "-opost", "-cs8"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cs8 is not negated according to the help:

litout        same as -parenb -istrip -opost cs8
Suggested change
flags = vec!["-parenb", "-istrip", "-opost", "-cs8"];
flags = vec!["-parenb", "-istrip", "-opost", "cs8"];

"cread", "-ignbrk", "brkint", "-inlcr", "-igncr", "icrnl", "icanon", "iexten",
"echo", "echoe", "echok", "-echonl", "-noflsh", "-ixoff", "-iutf8", "-iuclc",
"-xcase", "-ixany", "imaxbel", "-olcuc", "-ocrnl", "opost", "-ofill", "onlcr",
"-onocr", "-onlret", "n10", "cr0", "tab0", "bs0", "vt0", "ff0", "isig", "-tostop",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's nl0, not n10:

Suggested change
"-onocr", "-onlret", "n10", "cr0", "tab0", "bs0", "vt0", "ff0", "isig", "-tostop",
"-onocr", "-onlret", "nl0", "cr0", "tab0", "bs0", "vt0", "ff0", "isig", "-tostop",

"echo", "echoe", "echok", "-echonl", "-noflsh", "-ixoff", "-iutf8", "-iuclc",
"-xcase", "-ixany", "imaxbel", "-olcuc", "-ocrnl", "opost", "-ofill", "onlcr",
"-onocr", "-onlret", "n10", "cr0", "tab0", "bs0", "vt0", "ff0", "isig", "-tostop",
"-ofdel", "-echoprt", "echoctl", "echoke", "-extproc", "-flush0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's -flusho instead of -flush0:

Suggested change
"-ofdel", "-echoprt", "echoctl", "echoke", "-extproc", "-flush0",
"-ofdel", "-echoprt", "echoctl", "echoke", "-extproc", "-flusho",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thanks!

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@cakebaker cakebaker merged commit 2440278 into uutils:main Jul 10, 2025
76 checks passed
@cakebaker
Copy link
Contributor

Thanks!

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