fix stderr

This commit is contained in:
nora 2024-08-26 21:58:36 +02:00
parent a59bcb069d
commit 187478464c
4 changed files with 40 additions and 9 deletions

View file

@ -300,13 +300,23 @@ async fn handle_session_channel(user: String, channel: Channel) -> Result<()> {
let Ok(read) = read else {
bail!("failed to read");
};
let _ = state.channel.send(ChannelOperationKind::Data(read_buf[..read].to_vec())).await;
if read == 0 {
// EOF, close the stream.
state.reader = None;
} else {
let _ = state.channel.send(ChannelOperationKind::Data(read_buf[..read].to_vec())).await;
}
}
read = read_ext => {
let Ok(read) = read else {
bail!("failed to read");
};
let _ = state.channel.send(ChannelOperationKind::ExtendedData(1, read_ext_buf[..read].to_vec())).await;
if read == 0 {
// EOF, close the stream.
state.reader_ext = None;
} else {
let _ = state.channel.send(ChannelOperationKind::ExtendedData(1, read_ext_buf[..read].to_vec())).await;
}
}
}
}

View file

@ -1,3 +1,6 @@
#!/usr/bin/env bash
ssh -p "$PORT" "$HOST" echo jdklfsjdöklfd | grep "jdklfsjdöklfd"
# Important: redirect 2>&1 first before clobbering 1
ssh -p "$PORT" "$HOST" "echo jdklfsjdöklfd 1>&2" 2>&1 1>/dev/null | grep "jdklfsjdöklfd"