From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202508 header.b=q30P2aNq; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 03BE45A0272 for ; Tue, 30 Sep 2025 02:23:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1759191820; bh=Wapi/GgazMqVj0mnireh2NOxovK5lD+kHTS77es+SXQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q30P2aNqBAUun9xxHOl9XowjTvSkOFmFDfyB9xCSytMPAGPq/yxTnHpKSVvaY9Z/2 /PSTk2r3dCf80pGoBpwghSB2kQMBnV5dWPF+PumTFyNmx+G/OCKxQnkYwpSPQZl/ku LRCsom4twhQ2IcyAyjpZS3IbhkDO/ZjvwU5wFjm4YJHWGQpaQ2GnAoB3FoORAbfeL+ xalQX/l8XDXjMI9Y/QeHp2Rg3tKEgaLL6DNU958EhPUzCngrCZRFGObH5jQlT7ZaI3 ghEzY8QkILDAfzRvBO+X1NDJXbBGLAcPAz8F/B3PBBFnW6Saw3Rv/EBrueyR3RTLrB iFbvrbTGpZUVA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cbJgw6kz3z4wC3; Tue, 30 Sep 2025 10:23:40 +1000 (AEST) Date: Tue, 30 Sep 2025 10:23:39 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] test: Fix printf error when debug is enabled Message-ID: References: <20250929063014.17293-1-yuhuang@redhat.com> <20250930002417.55172be7@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5KZUtWZ25To/sFWG" Content-Disposition: inline In-Reply-To: <20250930002417.55172be7@elisabeth> Message-ID-Hash: SUAVHVNYYGCQFC7ZP5UEQXQKB6DNQGYP X-Message-ID-Hash: SUAVHVNYYGCQFC7ZP5UEQXQKB6DNQGYP X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Yumei Huang , passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --5KZUtWZ25To/sFWG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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: >=20 > > Running test pasta/tcp with debug enabled would get stuck with > > below error: > >=20 > > + printf 'DEBUG: ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[__GW= 6__%__IFNAME__]:10003\n' > > lib/term: line 38: printf: `_': invalid format character > >=20 > > The error occurs because printf interprets the % character as the > > start of a format specifier, and the following '_' isn't one of > > them. > >=20 > > Fix it by replacing 'printf "${*}\n"' with 'printf "%s\n" "$*"'. >=20 > 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: >=20 > Test layout: \033[1;34msingle passt instance with guest\033[0m.\n >=20 > 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. 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. --=20 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 --5KZUtWZ25To/sFWG Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmjbIwoACgkQzQJF27ox 2GcdahAAqH2DXir+tmLLZMWM6zgoX03hPC35MVTo4MsB8EgTDzaGliH2WYQYjCdp /RV+311sPmTmeeP4HY+Z+JsML5x+iTq9S9yBsTK4+opmMQuV/0mU6uoZvyom1Dp3 5OgK3kBx+oxTX4h1z7EiIWjKKX+vCaIG1TH+6xFOeZmC5vstvYxJQH7O1Iap/7hz 5k813zIul2PGaMxM10JUdOdmZcORX7p2xstVHg2TqT7KXAUXum5hGjp54JwatlSc zTzQ924U8OX/n521EKw4rmTQJVDuj3vOQ6PXHFim3sq1y7a1J5SzlkiM7EMXQfBy JLlTFKitt7FS4QB0BBAUWdAQsCZrM6nwNcrXvUDNMtKLhbX0zyZd3qxskKGtEQBG prR8DIru+Sa3yBcBHqiEDqwKLJJkS3HTMcipUAhreJqfTsSAKKYpvpmaVIFRkXks c6aRIhjS/W4XjYxL/FL1F3ywTcPpX7LiI3VBIelmJqdWxcJ8MxvpX0QqbS1Q0WjZ CTP/unDy+z7UxlXEcW/lq7BaoGMIlt5fHNi2DfKa1iDg3O+0+NuQ58ODStmfITEl /g+pEf0pug0Y7uWZnyVqMmbUizfGgdJDh+WpdIGcI1S8hE5JK49hY0DoQYuHTbsD Hy0GFoLEFVZSEiQmI0TuP1uxk6seR+e3JyQYMXFItjOLUatbeEY= =VG1O -----END PGP SIGNATURE----- --5KZUtWZ25To/sFWG--