On Tue, Sep 30, 2025 at 8:23 AM David Gibson
On Tue, Sep 30, 2025 at 12:24:17AM +0200, Stefano Brivio wrote:
On Mon, 29 Sep 2025 14:30:14 +0800 Yumei Huang
wrote: Running test pasta/tcp with debug enabled would get stuck with below error:
+ printf 'DEBUG: ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[__GW6__%__IFNAME__]:10003\n' lib/term: line 38: printf: `_': invalid format character
The error occurs because printf interprets the % character as the start of a format specifier, and the following '_' isn't one of them.
Fix it by replacing 'printf "${*}\n"' with 'printf "%s\n" "$*"'.
I'm not sure why, but this breaks colour highlights for me. Instead of seeing a part of this message in blue, now I get:
Test layout: \033[1;34msingle passt instance with guest\033[0m.\n
I can look into it if it only happens for me, or if needed.
Oh, that's interesting. I believe the colouring has been broken forever on Fedora, but I never got around to looking into it.
Well, the color worked fine on fedora before I changed to using "%s".
Figuring this out might reveal why. Maybe.
I realised I think I know why: those colour codes rely on turning "\033" into a terminal escape. printf(1) will do that in the format string, but not in %s parameters
$ printf "a\tb%sc\n " "\t" a b\tc
We can fix this either by moving the escape codes back into the format string, or using %b instead of %s, which explicitly interprets string escape codes.
Yes, %b fixes this. I will send v2 to update it and the brackets. Thanks.
-- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson
-- Thanks, Yumei Huang