Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

クローズ
#532 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #534 @lukewilliamboswell による — マージ済み

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
cli

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
122
フォーク
47
平均マージ
11時間 6分
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

roc-lang/basic-cli のほかの issue

roc-lang/basic-cli の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。