Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Cmd: send a child's stdout or stderr to a file

Geschlossen
#532 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Ein zugehöriger Pull Request wurde bereits gemerged.

  • #534 von @lukewilliamboswell — gemerged

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
rust
Bereich
cli

Rechercherichtung

Start by reading the existing Cmd stdout and stderr mode definitions and spawn implementation, then check their tests to see how child output is currently handled. The issue sketches file output modes with truncate or append behavior and merging stderr with stdout; compare those options with the existing API style. Done means a child can send stdout or stderr to a file as described, with tests covering the selected modes.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

A child's standard output can be inherited, discarded, captured, tee'd or piped, but not sent to a file. A long-running child whose output should end up on disk then needs a shell for the redirect:

child = Cmd.new("bash").args(["-c", "ssh … 'journalctl -k -f' > server.log 2>&1"]).spawn!()?

Our case: a race tool follows a remote server's kernel log and memory over one ssh session for hours, into a file (the "black box" read after a crash). The app is single-threaded and busy driving load the whole time, so it cannot read a Pipe and write the file itself. With Go we set cmd.Stdout to an *os.File.

A sketch, keeping Cmd's style:

StdoutMode : [Inherit, InheritStderr, Null, Capture, Tee, Pipe, File(Path, [Truncate, Append])]
StderrMode : [..., File(Path, [Truncate, Append]), MergeWithStdout]

child = Cmd.new("ssh").args(args).stdout(File("server.log", Truncate)).stderr(MergeWithStdout).spawn!()?

Opening the file in the host (with O_APPEND for Append) before the spawn would also make the redirect atomic in the way a shell's is. Could also take File.WriterOptions for its permissions.

Seen on 0.26.0-rc3.

Vorherrschende Sprache
Rust
Sterne
122
Forks
47
Ø Merge
11 Std. 6 Min.
Gemergte PRs (30 T.)
21

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus roc-lang/basic-cli

Alle Issues in roc-lang/basic-cli

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.