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=YSR1udBD; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id D22C65A0271 for ; Tue, 30 Sep 2025 13:13:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759230829; 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=zeHBLPJjVxw8YkOSJktb/KtTSY22GpKod6l6HhmgwSI=; b=YSR1udBDNc78G0JG6breQPZ2w0P9hvag0aBuWFNOc8xppbtcrc9oHzcVCfC8QCwHeeNrrB BDKjhIhIyAHPZUbCOtl0xVQwEHIIwTlHqP0IQ8x3Z6mQA6DlQpXlWTL7Hv9NnAPW2y5kKS Hy8LTwGF3qY9LbcGVfIgtNHp0Lwvhnk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-4LV-ePivPHuF5UxpV38ZRw-1; Tue, 30 Sep 2025 07:13:48 -0400 X-MC-Unique: 4LV-ePivPHuF5UxpV38ZRw-1 X-Mimecast-MFC-AGG-ID: 4LV-ePivPHuF5UxpV38ZRw_1759230827 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e407c600eso24382505e9.3 for ; Tue, 30 Sep 2025 04:13:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759230826; x=1759835626; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zeHBLPJjVxw8YkOSJktb/KtTSY22GpKod6l6HhmgwSI=; b=AhJa3f0/nWsherVRPDPCx2+0dAZhkPfhYFhr7zqb4kk0U+AbblOq/KgX471hvHso34 WnoLtrex/aQJT2oHfxpOCIKJP2XEOlSHssCbpqp4hsEyp0OcMBAIK+vM2hXRcgguyzKh 7BbP8EZO9smfYgNBIPE+4enVRjmAaecUV9qKsCsGis+0B4VmOXkrUTh3YUhlNqx3rKyj 9Q2Dx6D76FffLsjQaM1kMyPlfJSRcyNUgmN27LMZQHXTQS2sk94xY3IX1ZaO6cEfYJXB lXYOK/U3WhXBiaxd54RvVSGzJGcs1/CSs7zkH1my58Bbtme1nXVXYXlkwyJV7cJLyNcG pPYA== X-Forwarded-Encrypted: i=1; AJvYcCXX/04SonHY3OCeWKeVf7BdzKAoUfY/3lyDj48uu6VtP04v8K3thvj0d4dGmyt+z/gUkUQb03A/jEE=@passt.top X-Gm-Message-State: AOJu0YySsm5tgirfltACnmX63gVPnuiOMdFVk/9KzDh4AipZz0aS6AxO AVX7cZ364bBbZwQ8jG7eh7gbzpUB5hcn/4EJ0Qys47BPZQWVhkHXIB2QTTngyHkNLY7Q8n+Twp4 4PEboN4HNvIjG2RTW4hLYWp2cdXfv505VrNGokYuCEcrBOx+Z4te2Fw== X-Gm-Gg: ASbGnct+scXPIK7Ka6duigFmN5BxGZ1j7BaNumeRijLDSZ40+p7u5sdpjPBHKZblCE+ /vkpGxhBOhd+wuda0P/qZ0jjinN79qygFU4awsJXS9/wWN/pzyxKakDaEDKjgErMET+DC5tG2Ai 5sqNtkXB32GWJ/VomGaGMVEdOXBjd7rJTngqbLa97xexz4ySiy875rwoPpX7Udunmp38SYXF0K9 ZxNmg0bR5F3HMFo2i5+hf4NeI8s1HF9d0Ue7VM9+srW2qQ8+lVqsMeDzIdX7OwJiqlShtGkpdhv 7FBGL9d7zEqqm9HGmLRUeCnzmkhnyWgPaO8pd0Lhot+TAZMLpIDY817NmbOb4vDGm7K6j7uiUQ= = X-Received: by 2002:a05:600c:4512:b0:45f:28d2:bd38 with SMTP id 5b1f17b1804b1-46e329f9b5amr221398325e9.18.1759230826538; Tue, 30 Sep 2025 04:13:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMI+MakXsOTJq9nO4nIle/CeclOFgRCuXhSD3pSkE0HsNjGPCmiwuwJyp41duw9s984Wo+aA== X-Received: by 2002:a05:600c:4512:b0:45f:28d2:bd38 with SMTP id 5b1f17b1804b1-46e329f9b5amr221398145e9.18.1759230826108; Tue, 30 Sep 2025 04:13:46 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e572683ccsm53663515e9.22.2025.09.30.04.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Sep 2025 04:13:45 -0700 (PDT) Date: Tue, 30 Sep 2025 13:13:44 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] test: Fix printf error when debug is enabled Message-ID: <20250930131344.14de16d9@elisabeth> In-Reply-To: References: <20250929063014.17293-1-yuhuang@redhat.com> <20250930002417.55172be7@elisabeth> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: e7TNBwQ8StlmCaqQ6NgaE4CoLoUY-eOM62ewxfLg-0E_1759230827 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 3LHZMWHIRBUHMIDMNUGVUK3AUYCO5XIX X-Message-ID-Hash: 3LHZMWHIRBUHMIDMNUGVUK3AUYCO5XIX X-MailFrom: sbrivio@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: 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: On Tue, 30 Sep 2025 10:23:39 +1000 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. > 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. Oh, I didn't know about %b, nice. It's also in POSIX.1-2024, see point 7. here: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/printf.html#tag_20_96_13 ...side note for Yumei: the whole test suite _should_ be POSIX shell, that is, it doesn't rely on specific shell (e.g. Bash) implementations. For example, on Debian, Ubuntu, and others, the default shell for non-interactive usage (not what you have on terminal, but what executes scripts) is dash: https://wiki.ubuntu.com/DashAsBinSh https://wiki.archlinux.org/title/Dash So, if it's described in the POSIX specification (the one I just linked) it will almost certainly work everywhere. If not, it might break (but not necessarily). -- Stefano