Repository navigation
Open
Labels
Description
In the tauri_plugin_shell::process::Command, we have the output method which automatically collects all output from the sidecar command. The issue with it is that it inserts \n after each received chunk. In case of handling raw output (i.e. binary output; for example, images, PDFs, etc.), this behavior breaks the received buffer.
It would be nice to have a boolean parameter or a separate method for collecting the output without inserting \n between chunks.
plugins-workspace/plugins/shell/src/process/mod.rs
Lines 366 to 394 in 1a03e97
| pub async fn output(self) -> crate::Result<Output> { | |
| let (mut rx, _child) = self.spawn()?; | |
| let mut code = None; | |
| let mut stdout = Vec::new(); | |
| let mut stderr = Vec::new(); | |
| while let Some(event) = rx.recv().await { | |
| match event { | |
| CommandEvent::Terminated(payload) => { | |
| code = payload.code; | |
| } | |
| CommandEvent::Stdout(line) => { | |
| stdout.extend(line); | |
| stdout.push(NEWLINE_BYTE); | |
| } | |
| CommandEvent::Stderr(line) => { | |
| stderr.extend(line); | |
| stderr.push(NEWLINE_BYTE); | |
| } | |
| CommandEvent::Error(_) => {} | |
| } | |
| } | |
| Ok(Output { | |
| status: ExitStatus { code }, | |
| stdout, | |
| stderr, | |
| }) | |
| } |
Activity
Tunglies commentedon Dec 4, 2025
Seemed we already have boolean to determine formating.
niusia-ua commentedon Dec 4, 2025
This option only controls the reading method, but the
outputmethod still adds newlines.However, this option is indeed helpful - I use it in my custom stdout/stderr handlers.
If I understand it correctly, when we process a text output with
raw = false, theoutputmethod reads the output line by line and inserts newlines after each line. And withraw = true, it reads the output as is but still inserts newlines after each chunk.FabianLars commentedon Dec 4, 2025
as far as i understand #1231 that's not supposed to happen (or: the reason why raw=true was added in the first place)
fix(shell): return the bytes the process wrote from Command::output (fix