xargs: -d '\0' is rejected, and octal escapes need a leading 0

オープン 初心者向け
#925 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
cli

調査の方向性

src/xargs/mod.rs の parse_delimiter と、issue で言及されているテスト test_delimiter_parsing から始めてください。エスケープシーケンスの解析を本文中の GNU の例と比較し、その後、区切り文字の解析テストを実行してください。列挙された受け入れ対象と拒否対象のエスケープシーケンスが説明どおりに動作し、既存のテストが意図された \0 の動作を反映していれば完了です。

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

説明

$ printf 'a\0b' | xargs -d '\0' echo
Error: error: invalid value '\0' for '--delimiter <delimiter>': Invalid octal sequence: cannot parse integer from empty string
$ printf 'a\0b' | /usr/bin/xargs -d '\0' echo    # GNU findutils 4.10.0
a b
$ printf 'a:b' | xargs -d '\72' echo
Error: error: invalid value '\72' for '--delimiter <delimiter>': Invalid escape sequence: \72

GNU's manual says -d takes "an octal or hexadecimal escape code ... understood as for the printf command", and GNU xargs accepts \0, \72, \072, \101 and \0101. It rejects \400, \8 and \09.

In parse_delimiter (src/xargs/mod.rs:914), any escape that starts with 0 goes to the octal branch with the 0 removed, so \0 parses an empty string; the "0" => Ok(b'\0') arm below it never runs. Octal without a leading 0 isn't handled at all.

test_delimiter_parsing asserts parse_delimiter("\\0").is_err(), so matching GNU means changing that line. I have a fix that parses \ followed by octal digits as one octal value, with tests for the cases above; happy to open a PR if you want GNU's behaviour here.

uutils findutils main 505421d.

主要言語
Rust
スター
653
フォーク
115
平均マージ
1日 4時間
マージ済み PR(30日)
27

環境構築

はじめの一歩

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

uutils/findutils のほかの issue

uutils/findutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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