Skip to content

Conversation

@delan
Copy link
Contributor

@delan delan commented Jul 31, 2025

programs like curl(1), rsync(1), and dd(1) have progress output that rewrites one line “in place” by printing \rOUTPUT instead of OUTPUT\n. but StderrThread currently uses BufRead::lines, which only outputs a line when it sees LF (or CR LF), so this kind of progress output is invisible until the command is done (and then it overwrites the [INFO]).

this patch reworks StderrThread to treat CR (actually any sequence of CR and/or LF) as a line separator, when capture is false. no changes to the behaviour in capture mode. it also improves the handling of non-UTF-8 output.

@delan
Copy link
Contributor Author

delan commented Jul 31, 2025

use cmd_lib::{run_cmd, CmdResult};

#[cmd_lib::main]
fn main() -> CmdResult {
    run_cmd!(curl -o /dev/null "https://mirror.aarnet.edu.au/pub/OpenBSD/7.7/amd64/bsd")?;
    run_cmd!(dd if=/dev/urandom of=foo bs=1M count=10000 status=progress)?;
    run_cmd!(rsync -P foo bar >&2)?;

    Ok(())
}
before after
image image

@tao-guo tao-guo merged commit a72b039 into rust-shell-script:master Aug 1, 2025
1 check passed
@tao-guo
Copy link
Collaborator

tao-guo commented Aug 1, 2025

Thanks for taking time to improve this!

@delan delan mentioned this pull request Aug 2, 2025
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.

2 participants