sort: `-b` and `-M` still skip leading form feed and carriage return (follow-up to #14119)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
報告された動作は src/uu/sort/src/sort.rs にあり、-b によるキーの空白除去と month_parse の各処理経路に関係します。該当箇所と既存のソートテストを読み、空白除去と月順ソートに関する対象を絞ったテストを実行してください。C ロケールで Form Feed と Carriage Return が空白として読み飛ばされず、結果が報告された GNU の例と一致すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
#14119 (closed by PR #15436) was about uutils sort treating \f and \r as blanks. After #15436, -n, -h, -d and default field splitting match GNU. Two places still skip a leading \f or \r: the leading-blank trimming of -b (global or -k N b) and the month parser of -M. In the C locale a blank is only a space or a tab.
The GNU manual (sort invocation) says:
-b: Ignore leading blanks when finding sort keys in each line. By default a blank is a space or a tab, but the LC_CTYPE locale can change this.
-M: An initial string, consisting of any amount of blanks, followed by a month name abbreviation, is folded to UPPER case and compared in the order 'JAN' < 'FEB' < ... < 'DEC'. Invalid names compare low to valid names. ... By default a blank is a space or a tab
printf 'a\n\fb\n' | sort -k1b | od -An -c
# GNU 9.12: \f b \n a \n (the key keeps its \f, and \f < a)
# uutils: a \n \f b \n (the \f was skipped, so "b" > "a")
printf '\rFEB\nJAN\n' | sort -M | od -An -c
# GNU 9.12: \r F E B \n J A N \n ("\rFEB" is not a month, so it sorts low)
# uutils: J A N \n \r F E B \n
\f and \r behave the same in both cases.
Versions. uutils main eee56033d28bf7ef5cc816286b048779d57fb803 (2026-10-21, includes #15436) and the 0.12.0 release binary, macOS 26 aarch64 (the loop found it on Linux x86_64), LC_ALL=C, compared with GNU coreutils 9.12.
Where. src/uu/sort/src/sort.rs: the -b key trimming uses is_ascii_whitespace (in the key-selection code around position(|c| !c.is_ascii_whitespace())), and month_parse starts with line.trim_ascii_start().
Related: #14119 and PR #15436 cover -n, -h, -d and field splitting.
Found with an automated differential tester that compares uutils with GNU 9.12.
Reproduction steps
export LC_ALL=C
printf 'a\n\fb\n' | sort -k1b | od -An -c
# GNU 9.12: \f b \n a \n
# uutils: a \n \f b \n
printf '\rFEB\nJAN\n' | sort -M | od -An -c
# GNU 9.12: \r F E B \n J A N \n
# uutils: J A N \n \r F E B \n
- 主要言語
- Rust
- スター
- 24.3k
- フォーク
- 2.1k
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 325
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
uutils/coreutils のほかの issue
-
mv: wrong reason when the source can't be stat'ed (missing 'x/' says Not a directory, EACCES says No such file)対応中かも @emirmrkaljevic が今日担当しました。 オープンU - mv
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
uutils/coreutils#15704 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
U - expand U - unexpand
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
bug(sort): different -t multiple values is accepted, instead of rejected対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンU - sort
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
uutils/coreutils#15598 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
U - sort
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
uutils/coreutils#15596 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
U - sort
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
uutils/coreutils の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
farion1231/cc-switch#8829 ·
メンテナーはふだん 1 日以内に返信
-
bug ci good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
longbridge/gpui-kit#3677 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
ilya-zlobintsev/LACT#1235 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Shared Sink flush/close can complete without submitting buffered tasks対応中かも @RivTian が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
apalis-dev/apalis#797 ·
メンテナーはふだん 7 日以内に返信