sort: `-b` and `-M` still skip leading form feed and carriage return (follow-up to #14119)
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Il comportamento segnalato si trova in src/uu/sort/src/sort.rs, nei percorsi di rimozione degli spazi dalla chiave -b e month_parse. Leggi queste sezioni e i test di ordinamento esistenti, poi esegui i test mirati per la rimozione degli spazi e l’ordinamento per mese. Il lavoro è terminato quando Form Feed e Carriage Return non vengono ignorati come spazi nella locale C e i risultati corrispondono agli esempi GNU segnalati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
#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
- Lingua principale
- Rust
- Stelle
- 24.3k
- Fork
- 2.1k
- Merge medio
- 1g 21h
- PR unite (30g)
- 331
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di uutils/coreutils
-
U - sort
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
uutils/coreutils#15598 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
U - sort
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
uutils/coreutils#15596 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
U - sort
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
U - sort
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
I maintainer di solito rispondono entro 1 giorno
-
nl: unnumbered lines are padded with width+1 spaces, ignoring the length of `-s`Forse già presa @cakebaker l’ha presa 1 giorno fa. ApertaU - nl
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di uutils/coreutils
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
foxglove/mcap#1907 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted r-feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
servo/rust-smallvec#792 ·
I maintainer di solito rispondono entro 1 giorno
-
A-Unicode C-bug P-low
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
rust-lang/rustfmt#7210 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
callTracer with withLog: true includes logs from a reverted top-level call (diverges from geth)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
paradigmxyz/revm-inspectors#570 ·
I maintainer di solito rispondono entro 1 giorno