dircolors: '=' is not escaped and '^'/'\\' do not toggle the backslash state, unlike GNU

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

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

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

  • #16711 @saromanov による — マージされずにクローズ

評価

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

調査の方向性

src/uu/dircolors/src/dircolors.rs の escape() から始め、Issue に記載された GNU の need_backslash の規則と動作を比較してください。ls にある既存の parse_funky_string の処理を確認し、=, ^, バックスラッシュ、--print-ls-colors に焦点を当てたテストを追加または更新してください。対象の出力が GNU の例と一致し、表示専用の出力で文字がエスケープされない状態になれば完了です。

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

説明

U - dircolors
Description

escape() in src/uu/dircolors/src/dircolors.rs only escapes ' and :, and treats : as escaped unless the previous character is \. GNU coreutils uses a different quoting algorithm with a need_backslash state: \ and ^ toggle the state, and both : and = are escaped when the state says so. This produces different LS_COLORS output for several inputs.

Consequences:

  1. = is never escaped. The ls LS_COLORS parser treats \= as a literal = inside a glob item, so patterns containing = are mis-parsed when they are not escaped.
  2. ^ starts an escape sequence (^X control notation) in the ls parser, so it must toggle the backslash state; currently uutils escapes the : after ^, GNU does not.
  3. Because \ should toggle rather than disable escaping positionally, \\: must still escape the :.
  4. --print-ls-colors output escapes :, although GNU does not escape anything in that (display-only) mode.

Note: the missing csh escaping of ! is already tracked in #16496, this issue is only about the four points above.

Reproduction

Compared against GNU coreutils 9.11 (TERM=xterm, both reading a config from stdin via -):

$ printf 'exec x=y 01;33\n' | dircolors -b -
GNU:  LS_COLORS='ex=x\=y 01;33:';
uutils: LS_COLORS='ex=x=y 01;33:';

$ printf 'exec ^:x 01;33\n' | dircolors -b -
GNU:  LS_COLORS='ex=^:x 01;33:';
uutils: LS_COLORS='ex=^\:x 01;33:';

$ printf 'exec x\\:y 01;33\n' | dircolors -b -
GNU:  LS_COLORS='ex=x\\\:y 01;33:';
uutils: LS_COLORS='ex=x\\:y 01;33:';
Versions
  • uutils coreutils: master, commit a663b441b9b350ec54732974ae0cb7ae22e8f5b2 (also reproduces with the 0.10.0 binary shipped by the distro)
  • GNU coreutils: 9.11
  • Platform: Linux x86_64

The ls parser on both sides already understands \= / \: escapes (parse_funky_string), so fixing escape() does not break ls.

主要言語
Rust
スター
24.4k
フォーク
2.2k
平均マージ
2日 23時間
マージ済み PR(30日)
402

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

uutils/coreutils のほかの issue

uutils/coreutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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