uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.26k stars 1.24k forks source link

`printf`: extra spaces if padding number is not next to % #6519

Open Kev1n8 opened 1 week ago

Kev1n8 commented 1 week ago

Cases: printf "% -3.0f" 1 1 % cargo run printf "% -3.0f" 1 1 %(extra spaces here) cargo run printf '%-3.0f' 1` 1 %

printf "% 3.0d" 1 1 % cargo run printf "% 3.0d" 1 1 %(extra spaces here)

However, if the number is negative, the space will be filled with -, then there's no extra padding: cargo run printf "% -3.0f" -1 -1 %

related issue: #2774

Kev1n8 commented 1 week ago
Screenshot 2024-07-01 at 23 29 42
Kev1n8 commented 1 week ago

Also, zero padding is failing: ./target/debug/coreutils printf "%03d" -1 0-1%