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 C81CC2426E for ; Tue, 5 Mar 2024 23:49:01 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709678941; b=U4+HCuLOf0db4BzehBkjMysBdTO377QBVfmfWXEW7nsbrpFKmEU02AFiUShwTY0ouFuVMAnbHO k12OLqeGXU9rfWiEC5cPIRxZv/+T1S8qIyrs0odbK0te73fxFwKdc5NU/vNjH/rhUCWqfzDsrN NHNk6AGoo0uQNO4hvhddfC+iMRsBU0ttVfl73tku8k0KHFzDOCzqTe8Cm5csGRYkWYe6lWKjYa FmTxgzEnDkOPERAtB/f95WI8v50tboEIt+HiUTizCrx+M7r6OKSrUx5tKuLm3VXZjJPbmBfu32 1m6yyrP0g83QxVTpGUcTogc7EUnLt9etJNH3yVpLQo0hFQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f48.google.com) smtp.remote-ip=209.85.208.48; 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=1709678941; bh=ldKGt06oCzkKac5/p5uh4d48oEangj8T/gY9WLViIVE=; 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=CQuedJsIqAmjGzmulsJhT4vEOaebHEfLSgQBnnF2KO5/dD1zUVgpowi1p7u1xvu8+1eQmBoWxW fiEcVkiTcK93Yn0NkJdvOoZDxf3c0xwYYZSjwBAKwv7h5gpqjDxVxPaTkLncqqzAjSIG8cSyEr AiZX2inGfyHKSMUXcI3PjmM13Mgql05hlwIHui7iWoCyiFJMh463YZCmSudmcRXQqXGNYDNlDi VT9Q7Lq4Csv03B9bKJSOhoE4AbgVCMu7gKEcyi8Wdx/2jP2b1ZWfcs+fJBvyaX2S7HKX61cUx5 2qKKnj7YItaXUxhBdVer56yjZE7b0x4b/TFadrXNQn1D5A==; 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=ZTUgXOXTJ16QeOw8VleaM7ZKFAEkLb9jnJfHUZ46cVI=; b=l4hJ7lqP/WMdqnSEqQhpG18ZhV d6UYCOMkNe7xRlMOnfvTvLj225lxqg/Ay1UEI6u1p6ewqyDL/bBU3vkcCznkwuLR9/CVDNlkfBouJ DytPNrfLdxFO0Ddo47SBBX1aajbiwErvcbRhIjfP0LVYFr0L4g5/LjRaN6EHJpNrDXNsTP+PnQQfd IzhXQmT8GahxkoD9TCBIn8mkhxr5ipAUngKZXwXVJyx0zbl7/U3Sf6w92OyYrmV8dwuGWgz3X5eOl 2y5hrWBlSCW0sELA3O3G4+VD+VrKgjj+unr9joYeyfcwtBynpBgLV1U1Hlw7mTUgrkhOkGO/XPD4f gi+0NZ/A==; Received: by zero.zsh.org with local id 1rhdan-00057D-8B; Tue, 05 Mar 2024 22:49:01 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f48.google.com) smtp.remote-ip=209.85.208.48; 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-ed1-f48.google.com ([209.85.208.48]:44384) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rhdaE-0004mU-O1; Tue, 05 Mar 2024 22:48:27 +0000 Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5654f700705so8569457a12.1 for ; Tue, 05 Mar 2024 14:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1709678906; x=1710283706; 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=ZTUgXOXTJ16QeOw8VleaM7ZKFAEkLb9jnJfHUZ46cVI=; b=I0IwjVAWEknrSRU3diVV/46XNVm1Eqg4e4X9nmWcsnroxQmp5sWwUROST63Y1J2mB4 JNRoh8NQU5lHrArE7Kfy/9cqOVcY2SF6Y85EQkEGk4HLRZq0hF2yzZHP+pBrCRTlWnQe XiOf2MR9WOtBltp9ep8KXCEFXPOYA6Bc0DKXeQRdJRzFpJZUx9xC1Y55hE5a6FLLaecm tM+BOXU9FjYrFRVF8hJwBUYjQAbLH6Ly6F1orzwL2BQ66OknSge4i+xH17icXraGh6R1 nl+t62v5XB/Yz31e+NVWraVUnekXylHISw1AeOMa6i9Tok2Od0L/Zxh+sblgFsoQDIzc Df7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709678906; x=1710283706; 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=ZTUgXOXTJ16QeOw8VleaM7ZKFAEkLb9jnJfHUZ46cVI=; b=gkhYiH9K5VcFByr7MAn7Q24L64zw/wrkDFcM63UstexuIKNwSiM1awneeDPleHDJW5 wIa9y8WfKDBVf+SyzidQuqxZP1P9UuRO4D0POxlecvNUxhq3nwlJJEgrBMl+BRvVj2U7 Z7CoccSydeo1IL2JgAVO4Ff3cYj4xbZaSJ6BGsGP/cpaA5ioEXDCj6becHxNm8bd0Iid svZfHavNYKb19zUdCBEo6JPh0epf5sPnHSidqgVB1UQQJYSpFwD6V5d8dNKl9+SVnW4k 7J1NGokQ4q7A9yGFa2oEBPA7PfP8rvhZy6czrQBwDKqVy6la3p6C8DxENHAqCHuFkIoA dTyw== X-Gm-Message-State: AOJu0YxskYhmM+/yB9fDVJU7N+X4t+QZ3qMnVhGGHYp//K8387Nm+sH8 BWBKvcTR3vEUmeh+arsJNH3yAkwXbXU5IDyW9tOO8Ijh5vi/XhxE5P/CPPSeQSPegp37Tvry2pb whK/Gy9gSQjqgRyz877LzanRZreaVgEh5AKXo4lFFSYgXTZU= X-Google-Smtp-Source: AGHT+IHkatcDdp0BDpaqpHQmKrWZW9czqYswHCriy12zS0S++yY5U07uAB4k62kVEA3lKh9m3YZzbqnZ+y2G6A1XZ0g= X-Received: by 2002:a17:906:394c:b0:a44:e3d:68a8 with SMTP id g12-20020a170906394c00b00a440e3d68a8mr9596719eje.45.1709678905898; Tue, 05 Mar 2024 14:48:25 -0800 (PST) MIME-Version: 1.0 References: <20240305065606.ccr2ieheahslcpye@chazelas.org> In-Reply-To: <20240305065606.ccr2ieheahslcpye@chazelas.org> From: Bart Schaefer Date: Tue, 5 Mar 2024 14:48:00 -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: 52690 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 Mon, Mar 4, 2024 at 10:56=E2=80=AFPM Stephane Chazelas wrote: > > To me ${ cmd; } being the non-forking version of $(...) should > behave like $(...) in that regard. That's the starting point of this discussion, yes. > IMO, it's a bug in Bourne-like shells (and some others) that > $(...) removes *all* trailing newline characters, but removing > *one* is usually desired. Ignoring the many-vs.-one issue, the pivotal word here is "usually". We can't change the behavior of $(...) but parameter expansions already behave differently with respect to SH_WORD_SPLIT so we have precedent for leeway on ${ ... }. The suggested change would provide $(...)-like behavior for the usual case and a simple way to keep the newline(s) in the less-usual cases. > IIRC I already mentioned it here but maybe having a: > > ZSH_CMDSUBST_TRIM=3D This is both IMO way too complicated and also misses the point that newline trimming or not ought to be easily switchable in the context of a single expansion, not globally. So when I started the thread about ${ ... } the consensus was that it would be OK to always keep the newlines and if you don't want them in a particular case, you can write ${${ command }%$'\n'}. Since then it's been pointed out that a lot of uses of $(...) that would be replace-able with ${ ... } will break if the newlines are not stripped, and it's a bit of a pain to have to remember that nesting all the time. So the proposal made here has two goals: 1) Make it easy to replace many uses of $(...) 2) Make it easy to choose case-by-case whether to keep newlines Thus ${ ... } strips newlines like $(...) for #1 "${ ... }" keeps them for handling #2 and if you want full SH_WORD_SPLIT behavior you can still write ${=3D${ ... }} which is shorter and easier than the %$'\n' thing and strips newlines too. My strong inclination is to either go with this patch or leave it as is. The code change to implement this patch is literally two tokens. Thanks for the doc proofread.