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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 BE1DC236B1 for ; Wed, 6 Mar 2024 23:22:45 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709763765; b=sRq8yHu+WX2hKCHGg+Fdkci4MZ+kJEcVWjTBPKN6VSu0Jg2YAwhusN/V6SrceVsc+KmH8c6/LN COLNlSgulsY3fHcrEQZRx88WfktcJ4xNmQDBnqGETFuPgHybaWW5QAOPugFrktnASn1k6FTnry duA4sHI+7rBPqqJOyqFV7fjvEwaycYyNp8KdawDe+Ksg79x59+uNRAvVzQXC5dXV8zs0//ZvGo 1SDcRnwYZ6AkVJPLpelvh3t1yXyxU/0IVw0c26vLefprtVdMs4JTT3hEAp4301JW8tU6GBcGBi j9OjY5y1k1PTEjP1lWKwbA5qly6N37Rysn0x6UKdnMg5kA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709763765; bh=YJS9dQCcJSycL4Ek6dd9Do6Rk2SvNvFai0vCLf3Ra+Y=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=Ng2tG1YUekPoq8Vy/XFUOm8kJiSc8mokkpQFtK4UlJoY9iq1Y9+EOiCNnul1tAo4HM65jyWzSh yTyeIUFVn93UdUiMfdIszC8rMS1HpDKPzHg3anpsoyrpZWaNdUT+QU25DYxhAxZ4xfLVstsjnv cORx0pqibY67xiRsifttEQ5Dek0nioE8X7KMo7JLJrrgWBJJotnJvqx14qgWWAZl9Akn8Jogu2 ohGFcny9dG6PU95cH87sBsJJaxRfhJJTfCdgWmlW1N3vyHJsu5XIc/YceUqSbcvDKAEf2Wsnqf wz+MRWyH51/+ifExcT9mV4Zh9TDIOoZR3m/8uRlM8mnvuw==; 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:Cc:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=6bUVyUgJuJvApoqUrw6KkUt0VAUiT/AohqEsbCVf270=; b=KK3uwiwuNHxvswwbAnp6whNTsJ +DTkgCkXshAcPSlrjTlC/kiy0M09niiStRYS2yth5QZwgMBIH+CQvFJOxm5xic2bs94CuSFY9CaKQ +TyTl0+pU/GRah+yP5wfqoFua+Mz7Aie0goH6pLoF7LrL+BObGMh7Ya36nQGwIJpuJXjtx4ganEOo 8AEqhMX7lcrEAUXdsqlMsydvmIQ+v/yO6Qld1aAAIdZwdR2PulnHdmSsOpPcZB1KobqjpGydHbv3H AiJN19qb5HCgbHIwQ8svtdHAonHYWdrDn5HGwimglSWkWWdmlrRKMkVaV+13oviLhn6a61rD9bo9N rdmmifUg==; Received: by zero.zsh.org with local id 1rhzev-0007Mc-4G; Wed, 06 Mar 2024 22:22:45 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f42.google.com ([209.85.218.42]:58756) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rhzeg-000725-T6; Wed, 06 Mar 2024 22:22:31 +0000 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a293f2280c7so43504366b.1 for ; Wed, 06 Mar 2024 14:22:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709763750; x=1710368550; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6bUVyUgJuJvApoqUrw6KkUt0VAUiT/AohqEsbCVf270=; b=VGl6IA+L58K5up8USa3EJgZCUeapSWdCI7xihs/BpLv2LWd0DEymrWT6kFCvnqpTh2 szhezz6oPJRh4OmvXYAqqjGav2O20OxW28fC/cPpMMza4zF7BV1rRdkvbLb//NKr4N5m PWijAVnY5Dyj7bqKtzkqOGJkYIPslcPCNk9nTaNx27p47Tp7euwPKLHzVQti8VGYqFQB qIn2dThpXCfrcFhOxGl102H6lkOpSONMqCiahvwyMLTiXlwlk79NYjGraDjQ8Lil9BYK wLuyqKQL3pzRzkoB9tVC9rISJuH15IKpdMqGa1KLg2Ycj2HZrlUX7RyO8EYvtZPqSO1U rY3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709763750; x=1710368550; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6bUVyUgJuJvApoqUrw6KkUt0VAUiT/AohqEsbCVf270=; b=vtMPI84SFVqQDV+GYhzd2SP4qzBYbaRp4Z/sbGbtibHUKi4xZaGcsrzp7lfDwivmX8 UKgJQk5J56gTCuT831nhCfCzMiNG2rDfammx/JOKX9FCE63ABqYJ6BQou8gF0q5O7Oqp dpgw0Z/l0yzY9yXYSzVx3Hs7eCLcnvF6rUgZ+k55vIUHVMQPeDNN2IaGjcBY44IfK+hz MVDntNvAW3m7pK5r3j8P68A1Pdw1Tp1aYv1Xitb+DnCLFOiFBK1pfs3qtkEETmDBorfF pXH1lMxa7Mq1/RkIO7+SrkUuxafhf97RukOIVvAGC70aFHoilRG5y9Uhi5H99UpR6jvs 8qDg== X-Gm-Message-State: AOJu0YxzA/0vTgL1EnAkzabF9lEwFhi4wpdd5VUvERGnhvDSmadLqwE1 rhfBldlyO4s2CEk+eAQddEADlPAkHbNE0iZClFG15wKDc4ZCYYqikl4NxqNjfhZ1lv3oaiaIiuy ShZH+JpNJzpHe5P1bYwZfR6CgIFgPNSr/ X-Google-Smtp-Source: AGHT+IEQxVlb0Tf3I9JWTlkdhXK6r/YUIgHGiVgImz8uWLr4FokiVlAg3vGf35gYz5D26HfPkQ7IMPU5OudNmuU21rM= X-Received: by 2002:a17:906:1c81:b0:a45:98f3:997e with SMTP id g1-20020a1709061c8100b00a4598f3997emr5254676ejh.7.1709763749913; Wed, 06 Mar 2024 14:22:29 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:7208:5351:b0:7f:2ef1:5159 with HTTP; Wed, 6 Mar 2024 14:22:28 -0800 (PST) In-Reply-To: References: <20240305065606.ccr2ieheahslcpye@chazelas.org> <20240306175711.t3uz2sery3b6tbjw@chazelas.org> From: Mikael Magnusson Date: Wed, 6 Mar 2024 23:22:28 +0100 Message-ID: Subject: Re: [PATCH?] Nofork and removing newlines To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52699 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 3/6/24, Bart Schaefer wrote: > On Wed, Mar 6, 2024 at 9:57=E2=80=AFAM Stephane Chazelas > wrote: >> >> Sorry, I hadn't realised ${ cmd } also didn't do IFS-splitting, >> so it is indeed departing a lot from command substitution and >> assuming we don't care about keep compatibility with >> ksh93/mksh/bash, I agree the proposed behaviour makes sense > > If SH_WORD_SPLIT is in fact set (as when emulating) then it is > applied, so that's the other-shell-compatibility path. > >> Either way or always removing all newlines or always removing one >> newline or removing one newline when not quoted are fine with me. > > Thanks. Anyone else waiting to weigh in? These are just some observations with no real conclusion probably. 1) $(foo) will optimize away an extra fork if foo is an external command 2) ${ foo } will fork the same amount of times as 1) if foo is external and not at all if foo is a function. If you write a function that prints stuff, it is presumably pretty easy to just make it not print the extra newlines in the first place. If foo calls some external command that prints a newline then I suppose 1) and 2) are not super relevant arguments. "${ foo}" and ${ foo} having the same wordsplitting behavior but only differing in stripping newlines feels a bit magical and weird. I would feel surprised if it did wordsplitting without shwordsplit since it is an extension of the ${} syntax which doesn't do it. We could in theory add some new () flag, T for trim is free eg, ${(T)${ foo}} is somewhat more ergonomic than ${${ foo}%$'\n'} Is there some strong reason we could not allow ${(T) foo} btw? The space is syntactically kind of similar to other stuff that does work like ${(f)^param} and would save the extra ${}, but I didn't take a look at the code yet. --=20 Mikael Magnusson