From patchwork Thu Dec 15 00:25:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13073837 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88ACFC4332F for ; Thu, 15 Dec 2022 00:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229646AbiLOAZ5 (ORCPT ); Wed, 14 Dec 2022 19:25:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiLOAZ5 (ORCPT ); Wed, 14 Dec 2022 19:25:57 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5EB34D92 for ; Wed, 14 Dec 2022 16:25:56 -0800 (PST) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id AFB4A10B4 for ; Thu, 15 Dec 2022 01:25:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202211; t=1671063955; bh=KMrXQXyBVRt/LsW9dokblyY0M9e7a9S/s0A7Jk7tIPo=; h=Date:From:To:Subject:From; b=oBl0WD6rLmpWi7VTz8GfpikB7EgwwtwJbmOae1kOEbmdnJ2wMdfIRPTNOv8a7avR8 omhsRcoNMuDipFgZXHb36RSi+ff48SfNtjFdhnm48UwDlEveVjsy1nBxYwup4ehtoH mBG6Y6Tb/gfzRQePnKG/8Yq7YB/uRNTTRgAtcgCRo4hSp3SzAdYhG6borVj5Nu+T+w TTwrX7aiAXbkF0BIDu8SbBKFhog3DgOd6MxcM28ZbKJA4/lKe0BOE7GnkTS1UA46hO RRO0XEZqV1hyYesxsyX/ez86zrXmKsHFx+Sa+KV9Atwxljhp9W1pUYiOApNBJw1ovW wPT1NnQAam6RQ== Date: Thu, 15 Dec 2022 01:25:54 +0100 From: =?utf-8?b?0L3QsNCx?= To: dash@vger.kernel.org Subject: [PATCH v3 1/2] man: printf: reword to avoid confusion v/v Ar argument[s]/arguments Message-ID: <50b331b19b78fd56c5b2190f1f922a755e5f3270.1671063918.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20220429 Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org The current wording says that given printf a b c d a is the format, c and d are processed as noted, but b is unspecified --- Resending my patchset from August src/dash.1 | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/dash.1 b/src/dash.1 index ff02237..310f34e 100644 --- a/src/dash.1 +++ b/src/dash.1 @@ -1528,30 +1528,26 @@ With the option specified the output will be formatted suitably for non-interactive use. .\".Pp .It Xo printf Ar format -.Op Ar arguments ... +.Oo Ar value Oc Ns ... .Xc .Ic printf -formats and prints its arguments, after the first, under control -of the -.Ar format . -The -.Ar format -is a character string which contains three types of objects: plain characters, +formats and prints its arguments according to +.Ar format , +a character string which contains three types of objects: plain characters, which are simply copied to standard output, character escape sequences which are converted and copied to the standard output, and format specifications, each of which causes printing of the next successive -.Ar argument . +.Ar value . .Pp -The -.Ar arguments -after the first are treated as strings if the corresponding format is +Each +.Ar value +is treated as a string if the corresponding format specification is either .Cm b , -.Cm c +.Cm c , or .Cm s ; -otherwise it is evaluated as a C constant, with the following extensions: -.Pp +otherwise it is evaluated as a C constant, with the following additions: .Bl -bullet -offset indent -compact .It A leading plus or minus sign is allowed. @@ -1561,8 +1557,9 @@ If the leading character is a single or double quote, the value is the code of the next character. .El .Pp -The format string is reused as often as necessary to satisfy the -.Ar arguments . +The format string is reused as often as necessary until all +.Ar value Ns s +are consumed. Any extra format specifications are evaluated with zero or the null string. .Pp From patchwork Thu Dec 15 00:25:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13073838 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55CBAC4332F for ; Thu, 15 Dec 2022 00:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbiLOA0D (ORCPT ); Wed, 14 Dec 2022 19:26:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiLOA0C (ORCPT ); Wed, 14 Dec 2022 19:26:02 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 83903D92 for ; Wed, 14 Dec 2022 16:26:01 -0800 (PST) Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id DB33010B6 for ; Thu, 15 Dec 2022 01:26:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202211; t=1671063960; bh=InmYENqlveH5iqi6lE5OE1O97PhH6+Nd4rifHr0iTTk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=XhbBAmXwduVvgdc+FQ2yyMQqJJArqHRyM4+vnjXgVU2UWeYyvr2Pcfgl0vR+4Xhk7 +dWRdgpw6iR8d7BGmlNxTR/eZEY74sBKmeupZw/xgOsma/RgJQANQEE9+J4SqN8fuP nQHiTC3g+dHwuZsqzCoE/SJSgzBZdp+PtRIPbms9gb3MLGPRuef8l3Pl0gxQmS29cB vT1vlOmxWiRupBol9zHRSab/4VUkSvGqH8PdDV+vVl9T9QNOZnbe5VqjUWVFczVxjo JKJsiFbFh+E20/PXvMmH8yFnsUe5efvaPVdiHKv5kmaiAllRJ27sMwV0rD+ZJyRD54 DbAfFpwbHaAng== Date: Thu, 15 Dec 2022 01:25:59 +0100 From: =?utf-8?b?0L3QsNCx?= To: dash@vger.kernel.org Subject: [PATCH v3 2/2] man: printf: in 'X, X is a byte under dash Message-ID: <05324b17e76eef2401dbc3ee7d64366134a42d1d.1671063918.git.nabijaczleweli@nabijaczleweli.xyz> References: <50b331b19b78fd56c5b2190f1f922a755e5f3270.1671063918.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <50b331b19b78fd56c5b2190f1f922a755e5f3270.1671063918.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20220429 Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org Multiple issues: * the encoding is not always ASCII * what ASCII code is assigned to я * dash isn't internationalised (this is nonconformant but out of scope), and uses the next /byte/; in a UTF-8 locale: $ printf %d\\n \'ą 196 $ printf %d\\n \'я 196 this is in contrast to POSIX (and bash), which says: > If the leading character is a single-quote or double-quote, > the value shall be the numeric value in the underlying codeset > of the character following the single-quote or double-quote. (i.e. mbrtowc(&val, argv[n], ...)) --- src/dash.1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/dash.1 b/src/dash.1 index 310f34e..38cf020 100644 --- a/src/dash.1 +++ b/src/dash.1 @@ -1552,9 +1552,7 @@ otherwise it is evaluated as a C constant, with the following additions: .It A leading plus or minus sign is allowed. .It -If the leading character is a single or double quote, the value is the -.Tn ASCII -code of the next character. +If the leading character is a single or double quote, the value of the next byte. .El .Pp The format string is reused as often as necessary until all