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 6C2A2289CB for ; Fri, 8 Mar 2024 01:37:39 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709858259; b=g4J4FtFV8R6Wz1cYm7+IP99pl8cCTK6ZyfSeirQLmdWDiYa7SE0tpU7I8IpJE8+YeZXfcukr9A U0g/jCXwSjlNciZhxvmIKdd09XXT9G8CFiH6QCOcYIhSZ20q1JbRMl7VuAkyzQv49todWdaTql KspPwsbtR43UV58RXX+x8m/9GPz0mIPJyNakvj1VfkSqKQYFIZE4eGl7kDBXQwapnkvmylTEJl 3Ea2ErTnqpA5onzE83pUab+nVoSECQcdp5lfohhDz7bYA79ZqpqL2vl9mkvgjxSXIIj0YfR38J /YVbIkJBiMcZwh6x0Oi4SFYyN8KzJJInbm0BPGTDcnFF1w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f43.google.com) smtp.remote-ip=209.85.218.43; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709858259; bh=+IBbnhQn7VOND8xxRh7p2+SVB023WzT2dS/Kngx0/9Y=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=ZJai+o48VgQIHUagxv0GUIJu2zU4Tzlf4o9uYqiyXe+wEOkDY+/iODhZkRSne0ksBypHrInToz lCaw5+pLPzOQJJyJLiY/6BnSe/VIf/S1CZQ5qf28n20enJMNYsJo94PEQrOiPXiVywq4O9Lg3W W6ohb8/7vd1W5Ffm2IoFranOCbRuwp6xX8VUkBvinqxe9Px+HWpgPewKkK/ED/+9YWZj9Ehg5+ 3rpR0L76yTorujInMFaZbKiPrgA2/ry2iTZPukReFSLCSIlw+u5cIsrHOBnOBjMi7PzACckHr2 bvAoQAg+5G/l39WUBEcLNR4XwA+G4Imm1pItaXyCI3zV4w==; 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:Content-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=w+VTlKGocA1cawxQzoYf2hLK3yls8zcQsIX1fHY/pgA=; b=f6BXmuC6rTC/TV3UmnWSxUGem3 OaxHoEH46Ex4EsrNRCibHNpQbtx+iSEL9axEBbagCp7uQK5y/TbXUhqKSJvQTAEtS8lsD6gnNTKYq iwU9TD4tj5eDJbU9SPV97JUUGOg2T+5gliXJqF94KYB6KVbTCcKoBPlkySxmENBJtRosKDLhR2LtH +JsQZqsgQynwWbo1ycxJJzhGLuflnRsNvyZafIAvJ/3mitTk17haax4hrOsCN41bL4bAc+vcg4r9o HrMTPgU8i1HkDACoJE2kbpBewNxT+nqPuT+HsVCFwGZNRG08VTYbqg0SXXaXS6hv7PmewRe6Fjp68 qogekXFw==; Received: by zero.zsh.org with local id 1riOF0-000HRu-HQ; Fri, 08 Mar 2024 00:37:38 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f43.google.com) smtp.remote-ip=209.85.218.43; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f43.google.com ([209.85.218.43]:52631) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1riOEh-000HAW-Md; Fri, 08 Mar 2024 00:37:20 +0000 Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a4417fa396fso32971666b.1 for ; Thu, 07 Mar 2024 16:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1709858239; x=1710463039; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=w+VTlKGocA1cawxQzoYf2hLK3yls8zcQsIX1fHY/pgA=; b=rJr74ItI9ch0wgBB7lKMXMlyXBySbwaE9TkovKHmsZeh7NDT85sl+r2F8JUk6IbcMT h6LlUF2ox5XnyBrYmUtWhu/9UREG0WAWz8tJSt47w8XMpIvEU1bT6cXoLsji12oNDN3H IA+LHSp0M2L07vwikuO+SnD1TY3fmEi+wG8wbTnptWu97L4hILA5BEK1qun0/oHzhfqh zobVdAXjKrYpGhTQvYi8oiJ751stFM50hWiX10eZ2QjMRgsWVkvA+vmsFaOi1irlz9w3 MD5qJZmbO3DSmTA70lAm4w1BwayE3ytpNQV2hnIg+PtMQBIK4JWvXoVKYOQ5rY7g6AiX UGMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709858239; x=1710463039; h=content-transfer-encoding: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=w+VTlKGocA1cawxQzoYf2hLK3yls8zcQsIX1fHY/pgA=; b=g2I7tWo9Tk0L8KgqLjZsjsIIrOMxmZpmDnjHRqPk9yVVNFV2WcCd9CxWQQ5cAFYxlD KctO/iClQgqrG4N8eI8VIPzE98cQkoj7jLGJU5xwqhegfs7TtHCGP/coU/6TCrsE2e+h NZp/SVnti9uOJhM4yr/DBShMrDG7P0oORpX9rYM32Aap4K18FQkJOEoOAlbCOt6NZXUP +GsUWLJXkVqgIUOFynGoqhay47bhEZPhYemxmEuBy6lEuinChUHNNsjH6N7VqJ5g8dYr kAiwf4AbuGjFY98G4jb31iaBi/ubE7qYi0rhc/64w/mtaXo/m090Jv/5t4BFgX1yy3VS 4zxw== X-Gm-Message-State: AOJu0YxQzQmfgo59X3pTgzQK7xCoM7Jgu29GD848XozhiSXT/VJ9UC2t lHhswY32oS0t9Pc3i3vXrmTecGoDG/V+Rerx4BhaApvsAE3nHsSwtYTZcKPsFKe6piwut4k0WMw CpgfbYFxq47/46oar74l2yFZ0HdYv5zN0/fipBqxhhsGW+OR0lQ== X-Google-Smtp-Source: AGHT+IEXwCrdFmFi/wmABemNdXfOB/xEiLqXqLRx/VP4D5xfyjsWayZxVm2XSgnZOzEh0rHfyNK9O55Vg5frJh5aMFE= X-Received: by 2002:a17:906:454c:b0:a45:92c4:7892 with SMTP id s12-20020a170906454c00b00a4592c47892mr7056047ejq.56.1709858238751; Thu, 07 Mar 2024 16:37:18 -0800 (PST) MIME-Version: 1.0 References: <20240305065606.ccr2ieheahslcpye@chazelas.org> <20240306175711.t3uz2sery3b6tbjw@chazelas.org> <20240307071016.sk66axbt5n4cqv6c@chazelas.org> In-Reply-To: <20240307071016.sk66axbt5n4cqv6c@chazelas.org> From: Bart Schaefer Date: Thu, 7 Mar 2024 16:37:07 -0800 Message-ID: Subject: Re: [PATCH?] Nofork and removing newlines To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52710 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 Wed, Mar 6, 2024 at 11:10=E2=80=AFPM Stephane Chazelas wrote: > > For ${=3D${ foo }} that depends on whether $IFS contains a > (non-doubled) newline or not. True, but I think not really relevant, because nobody is (I hope) going to globally set a strange IFS in their dotfiles and still expect any normal behavior. > For (f), see also: > > $ printf '<%s>\n' "${(f@)${ print -l 'a b' '' 'c d' }}" > > <> > > <> That's because of the historic behavior of the (s::) flag where (f) is (ps:\n:). But as was pointed out elsewhere if you're not invoking an external command you can control this from inside the substitution: % printf '<%s>\n' "${(f@)${ print -nl 'a b' '' 'c d' }}" <> % Which leans a little in the direction of never trimming rather than of choosing how many to trim. It does however reveal a drawback in the quoting proposal, in that when nesting ${ ... } inside another quoted expansion there would be no way to disable newline retention. > We'd need to have a way to treat the separator as *delimiter* That would be a useful choice for (T) or some other new flag -- as in, do NOT "trim" the separator when splitting -- but I don't see how it helps decide whether to trim trailing newline(s) from ${ cmd } in the first place, because in the delimiter case you'd want to keep them? Just for grins ... % : ${|reply| typeset -ga reply local -i i=3D1 MBEGIN MEND local -n MATCH=3D'reply[i]' local pat=3D$'[^\n]#\n' : ${(*S)"${ print -l 'a b' '' 'c d' }"//(#m)($~pat)/$((i++))} } % typeset -p reply typeset -a reply=3D( $'a b\n' $'\n' $'c d\n' )