denoland / denoland/deno_task_shell

Issue with `xargs` parsing

Open
#142 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
139
Forks
25
PR merge metrics
No merged PRs in 30d

Description

A user of `pixi` reported that piping stdin into `deno_task_shell` has an issue (https://github.com/prefix-dev/pixi/issues/3462)

I created the folling reproducer:

```rust
use std::env;
use std::collections::HashMap;
use anyhow::{Context, Result};
use tokio;

#[tokio::main]
async fn main() -> Result<()> {
// Join the command and its arguments
let command_text = "xargs -0 printf '%s XXX'";
// let command_text = "which xargs";

// Parse the command
let list = deno_task_shell::parser::parse(&command_text)
.with_context(|| format!("Failed to parse command '{}'", command_text))?;

// Setup execution environment
let env_vars = std::env::vars().collect::>();
let cwd = std::env::current_dir()?;

// Execute the command
let exit_code = deno_task_shell::execute(
list,
env_vars,
&cwd,
Default::default(), // custom commands
Default::default(), // custom env
).await;

// Exit with the same code as the command
std::process::exit(exit_code);
}
```

When running:

```
printf 'a\0b\0' | cargo r --example repro
```

It prints `a XXXb XXX XXX`

While on a regular terminal,

```
╰─$ printf 'a\0b\0' | xargs -0 printf '%s XXX'
a XXXb XXX%
```

is printed.

Any ideas?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.