Closed bradleyharden closed 2 years ago
Hmm. Duct does let stderr inherit by default, so I would've expected this to work. And it might be that it's working for me. Here's what I'm running in Bash:
$ wget -q --show-progress -O - "https://mirror.math.princeton.edu/pub/ubuntu-iso/trusty/ubuntu-14.04.6-desktop-amd64.iso" | wc -c
SSL_INIT
- 0%[ ] 6.21M 1.56MB/s eta 14m 20s
(Not sure why it prints SSL_INIT
but whatever.) And here's what I'm running in Rust:
use duct::cmd;
fn main() -> anyhow::Result<()> {
let link =
"https://mirror.math.princeton.edu/pub/ubuntu-iso/trusty/ubuntu-14.04.6-desktop-amd64.iso";
let wget = cmd!("wget", "-q", "--show-progress", "-O", "-", &link);
let wc = cmd!("wc", "-c");
let _ = wget.pipe(wc).run()?;
Ok(())
}
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/scratch`
SSL_INIT
- 0%[ ] 2.85M 921KB/s eta 20m 25s
Sounds like that's different from what you're seeing in the second case?
Wow, quick reply. Yes, I believe that's not what I observed. Let me make sure everything I said is correct though. I'll double check.
Well, never mind I guess. It looks like it works for me too. I must have misunderstood something at first, confused myself, and ended up going down a long, pointless road. Sorry for the false alarm.
Interesting. No worries. And if you ever figure out what it was, feel free to reopen this ticket.
I've been using
duct
in a small script of mine. For the most part, it's been great. But I really struggled to figure this one out.I'm trying to do the bash equivalent of
Unfortunately, I couldn't figure out how to express this with
duct
. I think the main problem is thatwget
sees that it is not attached to a TTY, so it changes its progress bar output. I can capturestderr
, but it's very different than what I get when I run the command manually. On top of that, it seems like the progress bar updates come at an enormous rate. But if I don't capturestderr
, I don't see any output at all.I eventually dropped back to using
std::process
, and I got everything to work the first time. Here's what I came up withI don't have an exact record of everything I tried with
duct
, but they were all close to thisWhat's the difference here? Does
duct
not havestderr
inherit by default, likespawn
? I can't seem to figure out why the behavior is different.