ManageIQ / ManageIQ/awesome_spawn

[RFE] Pipes and redirects

Open
#57 3 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Ruby
Stars
9
Forks
14
PR merge metrics
No merged PRs in 30d

Description

Unix pipes and redirects are obviously extremely powerful for chaining multiple commands together, being able to support this nicely in AwesomeSpawn combined with AwesomeSpawn's CLI builder to prevent command injection.

Wishlist:
1. Easily provide `stdin`, `stdout`, and `stderr` for a process. Allow `String`, `File` / `IO` for stdin, `File` / `IO` for `stdout`/`stderr`.

Using pipes to write to a process' `stdin` is a great way to securely provide a password without it showing up in ENV vars, and giving the calling process' `$stdout` as the subcommands `stdout` allows for realtime output without waiting for the possibly long running command to finish

2. Easily chain commands together (aka pipe `stdout` from one to `stdin` of the next

Some bash examples that we should be able to do easily with AwesomeSpawn:
```bash
echo "hello" | sed 's/hello/goodbye/' > output.txt
```

```ruby
AwesomeSpawn.run("sed", :in => "hello", :params => ["s/hello/goodbye/"], :out => File.new("output.txt", "w"))
AwesomeSpawn.pipe("echo", :params => ["'hello'"]).pipe("sed", :params => ["'s/hello/goodbye/'"], :out => "output.txt").run
```

```bash
sudo dnf upgrade 2>/dev/null
```

```ruby
AwesomeSpawn.run("sudo", :stdin => "hunter2", :params => ["dnf", "upgrade"], :stdout => $stdout, :stderr => nil)
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing AwesomeSpawn's existing process-spawn API and CLI builder, since the issue does not name specific files or tests. Define how stdin, stdout, and stderr should accept strings, files, or IO objects, then determine how command chaining should work. Done means the shown pipe and redirect examples are supported securely, with coverage for the requested behaviors.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.