[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
printf doesn't zero-pad strings
From: |
tink |
Subject: |
printf doesn't zero-pad strings |
Date: |
Fri, 11 Aug 2023 10:06:22 +1200 |
Configuration Information [Automatically generated, do not change]:
Machine: aarch64
OS: darwin22.4.0
Compiler: clang
Compilation CFLAGS: -g -O2 -DNDEBUG
uname output: Darwin m1 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5
22:22:52 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8103 arm64
Machine Type: aarch64-apple-darwin22.4.0
Gawk Version: 5.2.2
Attestation 1:
I have read https://www.gnu.org/software/gawk/manual/html_node/Bugs.html.
Yes
Attestation 2:
I have not modified the sources before building gawk.
True
Description:
gawk doesn't zero-pad strings when using printf - it emits a space
instead.
I can confirm the same behaviour on Ubuntu, using a slightly older
gawk, GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0). The gawk
above was installed via brew.
The awk that ships w/ MacOS does the right thing, as does the one shipping
with OpenBSD 7.2.
(The Mac awk has no version info, but the man-page dates from 2020-11-24)
andrej@m1:~/tmp8$ echo a |awk '{printf "%02s\n", $1}'
0a
andrej@blowfish:~ $ awk -V
awk version 20220912
andrej@blowfish:~ $ echo a|awk '{printf "%02s\n", $1}'
0a
andrej@blowfish:~ $
Repeat-By:
$ LC_ALL=C echo a |gawk '{printf "%02s\n", $1}'
a
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
- printf doesn't zero-pad strings,
tink <=