From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13847 invoked from network); 23 Apr 2021 16:53:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Apr 2021 16:53:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1619196825; b=s6PI5Co77SY0lFqb8YB57S+4NJeO/EAmNLkd+4xnuPf8tUOrNc8tOQ9UJdeT1vf9uLCEouuj/G mapnH946paqTZkmFHyK+o7IX4m/nuZrcvuHZwDUa4BFAD7tZzyzNLErwXzXEaysdAZ87fYzRAt jSGHkcnFt9bI7wOmUDJpIUlRDEfrw/KFJ9qMTO+TCziJ6P4GU1xNHIy2L8befgEKENKEQLVcXc S9Pp+BWB99REgoz2yv7jThK/dDOUB0fV6kTmytipdsTp+q0vTGZFtiDCeGNaVmNHG1F7za9cXf Qm9eNaQKCD7m6fRYFfUfFMeZ3OL9ahnMImZnhGTjAWEHsg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1619196825; bh=mbYn2WSzn2+GwS+PHfVFJVyV6RSOmyQlUCte5UhyuVk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature; b=A0PvqKLZdVsd3Zd70P3+6k5KfLQLFB1417UmJPE+2uDMbDa1mbHC8APPU0U+UPjzuVkmqLwyiV p0iX7oxBdO0RrQH8ipfGzgoICcoiyNusgWgkW8aWzmpsl+dwAkDU7zgaQqK496UIHgEfcSnHR+ p6E/dO2N/MUQyZG4G/WlAGxm98OZo84d0LOcfMUMcw3p/U24l8qG6lA3H++6uVPTsb5TygQRNg VpsvCDqqm05MPEE+JTmDRuIw8ltXhJylVFA+QfP9TTocCHbuM+cU75/2RP+bhCiObaZLHwdPug b5ln6MnMC9qQajJrnHMeqlwIEgIexs4PPOrUbn3Tj4Yymw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=p/3r7v8YQhbbrwp1fxV/7ofKCudduoQUJ1afvUvRI7k=; b=q4nXbQBAm8cz7PvRVXzIdPfcmj +quCcZzj9kNljhpfMKjQVr3ZTRNMxV0FQAbq8ndmtyL88qz8z0rdzx/oEhJ8YDFuqeQdpMjDuZ8Al ykoasaw1BUxgLsd0o+TbZZC3RAPYmR8hpxQzyBiVgbi/tUVT+MeWyrKoRw7RJEsGpoRG7CsJNMS2D o4Mj1GST5kjl4RNPqB0QbqhcDbi8bfQ+t7/2YAuT8m3uxpqJHss9T5EFVQKWBz8/ffTupCY7StXpJ +IZ4d9dIO6PbF4YRzR5hwXO6aNCLHsRhio4Rin14UMuFthVjYUwn4FpRl5jWIahlHnSaNidY8FHI7 Bao0MkXw==; Received: from authenticated user by zero.zsh.org with local id 1lZz3p-0006AJ-3G; Fri, 23 Apr 2021 16:53:45 +0000 Authentication-Results: zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none Received: from joooj.vinc17.net ([155.133.131.76]:53308) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lZz3Y-0005uS-Do; Fri, 23 Apr 2021 16:53:29 +0000 Received: from smtp-zira.vinc17.net (unknown [IPv6:2a01:cb19:869c:7700:6150:861a:e24c:595d]) by joooj.vinc17.net (Postfix) with ESMTPSA id 0E1D82D4; Fri, 23 Apr 2021 18:53:28 +0200 (CEST) Received: by zira.vinc17.org (Postfix, from userid 1000) id 2F689C22B66; Fri, 23 Apr 2021 18:53:26 +0200 (CEST) Date: Fri, 23 Apr 2021 18:53:26 +0200 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: Re: sh emulation POSIX non-conformances (printf %10s and bytes vs character) Message-ID: <20210423165326.GB2033191@zira.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org References: <7FD930F4-37CD-402B-9A06-893818856199@dana.is> <20210411175726.hxnm33mxoska2tsm@chazelas.org> <20210411194205.e7mr2wx33wlkq3rs@chazelas.org> <20210422135934.GA154089@zira.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.0.6+158 (8162c129) vl-136976 (2021-04-22) X-Seq: 48669 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 2021-04-22 12:22:12 -0700, Bart Schaefer wrote: > On Thu, Apr 22, 2021 at 7:01 AM Vincent Lefevre wrote: > > > > > POSIX requires: > > > > > > | Stéphane| > > > | Chazelas| > > > > I would think that's intentional, at least for the precision > > (e.g. %.4s) in order to prevent buffer overflow. > > That makes sense for C-ish languages, but I would think it was a bad > idea in general for the shell to allocate buffer sizes based on user > input. > > Someone can probably point to the rationale document, but I'm guessing > this is really because of equivalence with sprintf() formats. Some file formats have fields with a byte-size limit. Providing more than this limit could have unexpected effects. One may also want to limit the size of generated filenames (see NAME_MAX). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)