git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix '\%o' for printf from coreutils

From
Kacper Kornet <draenog@pld-linux.org>
Date
Oct 31, 2013, 11:51 UTC
Message-ID
<20131031115131.GA28379@camk.edu.pl>

The printf utility provided by coreutils when interpreting '\%o' format does not recognize %o as formatting directive. For example printf '\%o 0 returns \%o and warning: ignoring excess arguments, starting with ‘0’, which results in failed tests in t5309-pack-delta-cycles.sh. In most shells the test ends with success as the printf is a builtin utility.

Fix it by using '\\%o' which is interpreted consistently in all versions of printf.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
---

I've found it while testing v1.8.5-rc0 with mksh which does not provide a builtin printf.

Kacper
 t/lib-pack.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/lib-pack.sh b/t/lib-pack.sh
index 7e8685b..b96e125 100644
--- a/t/lib-pack.sh
+++ b/t/lib-pack.sh
@@ -12,10 +12,10 @@
 # Print the big-endian 4-byte octal representation of $1
 uint32_octal () {
 	n=$1
-	printf '\%o' $(($n / 16777216)); n=$((n % 16777216))
-	printf '\%o' $(($n /    65536)); n=$((n %    65536))
-	printf '\%o' $(($n /      256)); n=$((n %      256))
-	printf '\%o' $(($n           ));
+	printf '\\%o' $(($n / 16777216)); n=$((n % 16777216))
+	printf '\\%o' $(($n /    65536)); n=$((n %    65536))
+	printf '\\%o' $(($n /      256)); n=$((n %      256))
+	printf '\\%o' $(($n           ));
 }
 
 # Print the big-endian 4-byte binary representation of $1
-- 
1.8.4.2

-- 
  Kacper Kornet
Next: Jeff King
Message 1 of 2 in “Fix '\%o' for printf from coreutils”
  1. Fix '\%o' for printf from coreutilsKacper Kornet, Oct 31, 2013
  2. Jeff KingOct 31, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.