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

sort: `-b` and `-M` still skip leading form feed and carriage return (follow-up to #14119)

クローズ 初心者向け
#15,588 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

@ozenyunus35 がすでに取り組んでいます。

2026年10月22日 から。

  • #15647 @ozenyunus35 による — オープン

評価

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

調査の方向性

報告された動作は src/uu/sort/src/sort.rs にあり、-b によるキーの空白除去と month_parse の各処理経路に関係します。該当箇所と既存のソートテストを読み、空白除去と月順ソートに関する対象を絞ったテストを実行してください。C ロケールで Form Feed と Carriage Return が空白として読み飛ばされず、結果が報告された GNU の例と一致すれば完了です。

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

説明

U - sort

#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

環境構築

Codespaces で開く

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

はじめの一歩

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

uutils/coreutils のほかの issue

uutils/coreutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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