From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CPPs5K1K; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id C53D55A026F for ; Tue, 30 Sep 2025 03:32:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759195945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DXDvaF/ybzA5p4+O8Lo4H/FM0nF9yf6/HgP5wZp+8q4=; b=CPPs5K1KlI0WKAsq782L7HvaRWky0AABLJzKq9ou24s4La5s8bfecpoExpmMaqvMp1V8yW ks3waYIZxNFQM9Or4jSTxwfemEO5AOR9zq7cULHzGkXfK4pcr8yGikKpY0nRZ0+HUE6nxf j/C58K+OzbE4JA8V6tDKeu4uxNh3oQk= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-ps7SjQaNOeORK1QbUGk4oQ-1; Mon, 29 Sep 2025 21:32:23 -0400 X-MC-Unique: ps7SjQaNOeORK1QbUGk4oQ-1 X-Mimecast-MFC-AGG-ID: ps7SjQaNOeORK1QbUGk4oQ_1759195943 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-62fcb646334so8192651a12.2 for ; Mon, 29 Sep 2025 18:32:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759195943; x=1759800743; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DXDvaF/ybzA5p4+O8Lo4H/FM0nF9yf6/HgP5wZp+8q4=; b=Ug8iXObW7DPfXXG3ihvKblNu7M4s/p8gbmuq3/FaccuZ/VN2ZCg3el3+cXYy67QC/M 4MMwZ7GDis5XgTYnXGfXG7EpIrAl6jaXdrNevshd/QtMtv3gXBgrlmhUjFJfWYssMcjE xfNq/JPoMEKknzmg6PY703MKCsGM0RlHLVBMU44J1rBaS8K35kSB9sXmqMcfnPusJfBH f3S/JZs0796vnHJAP2fyWk3xCC61ODEV33QCFo6uQieHS/sJMuRe8S5IvX2NvEEzmGxl tqXB8q3yioobSbYBdMqTcTdGIhx+0D3Rwg3juset9bGRQNx/DjGc6CPujcQ7XdnY4Pnj buRg== X-Forwarded-Encrypted: i=1; AJvYcCWK9fNnoQj+Ui0TaLJKYRvV83WRH7rWgSQoIWlzSKQ9cAtG8jscolHUbyFK3OlNk4cyC6f8NzaraPY=@passt.top X-Gm-Message-State: AOJu0Yx7UWbY2b8Xyes2O4QtOBd1K8huk9dZI8ZWaBKkn9p2wWbxJhV8 4NQvwoM2BIfZvmjs2sU/gVKfSFMrAxPke0MmG1YXe4798z+VXVWxX6D0sLZsPCUKXQZow7oNNP7 hWjPTrrQZto6IYNkdTwGpTAvjmHr3F/EtA3ELz11e3oISeLKv9+d2COTFZ4Ip6G6bwEE/8yWZ67 sZ+NGHPYHxsz9ymW91qPiuJ308YaRl X-Gm-Gg: ASbGncsECX3dAlC79JLLWAMW8bQ8nernLsXiwuORqRbIwsqJt1siYWJ9dHZ5W1BgHYx YuS/mG3yAhuRpqhxrYaMA7sTEo8qTqFS/fbnBcEMT26B+J/YkenvIgksR+FzJ2XJLXCSRj/qeKM KYKvUNhEvTmg2sxjvi5ebvOWaden4= X-Received: by 2002:a05:6402:50d4:b0:62f:50ff:b675 with SMTP id 4fb4d7f45d1cf-634c9c9ca65mr12031804a12.33.1759195942626; Mon, 29 Sep 2025 18:32:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEraPvsbW+6pWHrhU5VF5vAjZrT2erFawZHWQCyEbXXsou7GGgkKXH2BMWfVSIgua2xFC4/o2iHLa+s3zpWf9M= X-Received: by 2002:a05:6402:50d4:b0:62f:50ff:b675 with SMTP id 4fb4d7f45d1cf-634c9c9ca65mr12031782a12.33.1759195942212; Mon, 29 Sep 2025 18:32:22 -0700 (PDT) MIME-Version: 1.0 References: <20250929063014.17293-1-yuhuang@redhat.com> <20250930002417.55172be7@elisabeth> In-Reply-To: From: Yumei Huang Date: Tue, 30 Sep 2025 09:32:11 +0800 X-Gm-Features: AS18NWBTQm0ReIzQyVKby39kJvQU9x87-P85QsZgk6aNC5rvQOI5E766NtuBy40 Message-ID: Subject: Re: [PATCH] test: Fix printf error when debug is enabled To: David Gibson X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: BgJix7WlOU01uOPyg7q07hh9AQ2M-OcZwhi5ih-9pu8_1759195943 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NDCYM3YLVWQOY6RZZ2WCT6WDPLDEJX4E X-Message-ID-Hash: NDCYM3YLVWQOY6RZZ2WCT6WDPLDEJX4E X-MailFrom: yuhuang@redhat.com 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: Stefano Brivio , 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: On Tue, Sep 30, 2025 at 8:23=E2=80=AFAM David Gibson wrote: > > 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 wa= y > | around. > http://www.ozlabs.org/~dgibson --=20 Thanks, Yumei Huang