From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id F32B5273BA for ; Thu, 7 Mar 2024 08:10:36 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709795436; b=iGG3Mo191aoQAdAOuJqSc4I/aZ76vspWTJWKcKo2oUa4xlaw6CMPS6m1EIcK0RqCBS2/vlxiWy qJQYd5I7+T97TM/MkhS8iMaL6Gow4sdTfwwGtq5yfuf1uy25XTpU+DHtCBr8ICmBNWlECBKS6u Q3qG0tRd8v/zy6AY2EITNY/gRIKYzWs7OCYVrrIYsGc2VnHOXtn2KnJxQpPH69hemP8uMG26f0 rNnVkH/1oLWXtjLeiTCiVL+3YX+7gKR3K/pFf14YpjnhSf8pEfVwZqSNOBJP612yYWn0uTzCO7 dIkUI0jhQUkLzSySX+KKcBw3AV6R1vmDkembHIh46goO2g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709795436; bh=1wrM3Hn89OmvMewvBsNctuvogL8EgrUsKk+X02xzzuI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=X++DeV7PYRIlhdzFd2xCjr1aGD3l5WU51kNIbb5CsvGCXlo1WoRBF/XDfLwg2K0zzshz+BgNJT +P+Vwf7TG8Kh4UBHO64P2vXKfE6EzvwGGlLyf/athcogJktET/GX1aD4jpmJm7Zk71q99SmYsG 9SeD93RhABB9Q+CbA5iRr8mfzCOohw0KMshxQr51ANGwffnxW2Ex5rYe+8UWREh/8+4yCqEfoD 5RVATNQRIuWrlupBb1tS42RzxW2flfJFHNeFnF0voFBuwz01KqUl6N/qX/B10svE9rri12x3Kt ad8BobXzG8JcLGT8YtiTGQMb4UK9YaeMNCNJWt8+4pijLw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=MFFgsx3bCPEBWZTRd+EGzbRWOuPde22eibIfIRRMuWY=; b=WunRyG5V6qW+LB5SS0upJtux+4 jIyGrJ178cAnfsaALv+RXXATBtP/neH5lkHztud3skdjc8iXL/JwIUpml+SYWFb/DhIOUDwIDy8lf XWAB1g9RQ498FJbhMFeWHCn4RFFxriXVzieRvfHGDm6hOP4FhBxB68QVU7ZAz1g47XfNpYhf34v/a AaYnikrzEyfng9d7af+/gbf8NiMefooG4SlCmIDembIiFnKQ328kl2Rimv8WqGCaZ4k8n76/mZR+X tldaIrUr4ecEkdTjVu50eZWv4vsbgLN6NrBo9ctIs/Ajc94BIK5Odvw3B40CmwilhvuivUMpagSUx qkt1+IQA==; Received: by zero.zsh.org with local id 1ri7tk-0004jz-CC; Thu, 07 Mar 2024 07:10:36 +0000 Authentication-Results: zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none Received: from relay1-d.mail.gandi.net ([217.70.183.193]:34251) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1ri7tT-0004PI-Kv; Thu, 07 Mar 2024 07:10:20 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id C311E240004; Thu, 7 Mar 2024 07:10:17 +0000 (UTC) Date: Thu, 7 Mar 2024 07:10:16 +0000 From: Stephane Chazelas To: Bart Schaefer Cc: Mikael Magnusson , Zsh hackers list Subject: Re: [PATCH?] Nofork and removing newlines Message-ID: <20240307071016.sk66axbt5n4cqv6c@chazelas.org> Mail-Followup-To: Bart Schaefer , Mikael Magnusson , Zsh hackers list References: <20240305065606.ccr2ieheahslcpye@chazelas.org> <20240306175711.t3uz2sery3b6tbjw@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-GND-Sasl: stephane@chazelas.org X-Seq: 52706 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: 2024-03-06 20:53:28 -0800, Bart Schaefer: [...] > > "${ foo}" and ${ foo} having the same wordsplitting behavior but only > > differing in stripping newlines feels a bit magical and weird. > > One question (and sort of the point) is whether anyone would really > notice. If you put it in quotes you're expecting a literal result, > and if you (for example) assign it unquoted to a scalar you're > expecting it to "just work" the way assigning $(foo) would. It's a > bit unusual but it seems to preserve the principle of least surprise, > and it uses the least amount of extra syntax. > > On the other hand I'm not highly invested in this. In the absence of > this (no)quoting behavior, I've found I nearly always want ${=${ foo > }} or ${(f)${ foo }}, each of which gives exactly the same result with > or without trimming. [...] For ${=${ foo }} that depends on whether $IFS contains a (non-doubled) newline or not. Without trimming: $ IFS=: $ printf '<%s>\n' ${=${ getconf PATH }} $ IFS=$'\n\n' $ printf '<%s>\n' ${=${ seq 3 }} <1> <2> <3> <> For (f), see also: $ printf '<%s>\n' "${(f@)${ print -l 'a b' '' 'c d' }}" <> <> Like with IFS=$'\n\n', those are typically the cases where you do want to preserve empty lines. In both cases, trimming one (and only one) newline character would lead to a better behaviour. One exception would be in: lines=( "${(f@)${ print -l '' }}" ) Where you'd get no line instead of one empty line. Though at the moment, you get: $ lines=( "${(f@)${ print -l '' }}" ) $ typeset -p lines typeset -a lines=( '' '' ) (2 empty lines) which is not better. We'd need to have a way to treat the separator as *delimiter* instead (as POSIX requires for IFS splitting despite the S in IFS; both "delimiting" and "separating" have their use). -- Stephane