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 D963221598 for ; Wed, 6 Mar 2024 20:43:29 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709754209; b=bHRAlkmLkmuLI9RWWlEGgGTLRiMqlatigdkatMFJzWofS6QMk3TTk7F4ZrIn37cDveQq19PMr4 /c8aA/1GtSiJ5C4c+KEk3rIKxRC1c78HEzVaZWyypJWTDLJloJSCfCtwpfGtcq4M3J/pXx0JJk ECQQuKrcFcxUwMCITLURrw66g2tcQwLmmTRZ0y+vgu5Aej3CkX0DmO4uhPaLKlQLabq//cgQp4 Y9qreTQcengBQmTCwUCkhQsBPZpNT0whVzWT93Or6txQZeVlLEmZ+Cr541O5Q46Zv42lF7PRWC +NK+4OD1PCuv+Ao1mBU7lkofWbZ1GVH11dyCK4Ou6uSHUA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay5-d.mail.gandi.net) smtp.remote-ip=217.70.183.197; 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=1709754209; bh=am8+0d89m/XOVYcQs2L9R5eEdLllgU5JeCcAh7kD4hE=; 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=TgfSWBEEVb0bQzCGv75Ex6r28XpV9qXorIhrzNEKoFcrEKJp8sTObThqzGYoturbBSikKmQmeq 6/tZeRDSNY0fxNdSAcM28/xAumMpiu820RJmK5L9QqlFZ7GCVTUVvWmt002fEmMMALCjAlQICX bVeTamy/vQTlNptmkxGVdOlI1+whcOIhXlSTebQlHIKoV7McVzugKHPprsehdOLLdOnjOHbdWS G6Xdm8WUslUpnxtJ2QGOdcETh6TmPNRvLnlSz5huHvvRDHMuFngOTfHAll6u1G6VT2Fsr7zhEl R00EmwSVAdEkSDTAa4W+oKws5a2SMzcJv0BYPdHJuO/G4g==; 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=30LOLVGbxuJTZFv6rTxh3pzJS9prE1bdZ7WThzHde2M=; b=gzLZpSiksLn90M8ydPFxA/BVK8 p4dUUGJTZtJATe8jShSBhLhvwALEpzSZgmvA759ypTlPiDr0xVPJJp3aFXsvCiGfV2zjkAMhikCTj I2VpD1rHd25P/fnZXgjWp5moce21VBc+luGOOlEBUESv0lD/nH0WK4d2YNkv3xh3eC44SVvZrufJB QznaepZbtS3WOsWjuMdf0aTh/c269dB3g5LxCGIPK+3sM6vHpU49tsa8c2suimEJ6a145xoZhsZBb U6fsZEptvB/g4shalbj+x+iK93APvC74Qz4DI+nsuwmF6KjJc75j3sTjAbjqagf1td4BOUOcm1TGT LT/tLbww==; Received: by zero.zsh.org with local id 1rhxAn-000Pza-8R; Wed, 06 Mar 2024 19:43:29 +0000 Authentication-Results: zsh.org; iprev=pass (relay5-d.mail.gandi.net) smtp.remote-ip=217.70.183.197; dmarc=none header.from=chazelas.org; arc=none Received: from relay5-d.mail.gandi.net ([217.70.183.197]:37907) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1rhxAZ-000Pf2-F1; Wed, 06 Mar 2024 19:43:15 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 85EB91C0003; Wed, 6 Mar 2024 19:43:14 +0000 (UTC) Date: Wed, 6 Mar 2024 19:43:13 +0000 From: Stephane Chazelas To: Bart Schaefer Cc: Zsh hackers list Subject: Re: [PATCH?] Nofork and removing newlines Message-ID: <20240306194313.nubyjm6rdoqtzes6@chazelas.org> Mail-Followup-To: Bart Schaefer , Zsh hackers list References: <20240305065606.ccr2ieheahslcpye@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: 52697 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-05 14:48:00 -0800, Bart Schaefer: [...] > 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. [...] For reference, some other shells that can keep trailing newline in command subtitution: rc: whole_output = ``(){cmd and its args} fish: set whole_output (cmd and its args | string collect -aN) (-aN short for --allow-empty --no-trim-newlines). fish's command substitution ( (...) and also $(...) including inside "..." in recent versions) doesn't fork so is closer to ksh93's ${ cmd; } than ksh86's $(...) POSIX/Korn-like shells: I'm sure everyone will have their own variant, but get_whole_output() { eval " $1"'=$(shift; "$@"; ret=$?; echo .; exit "$ret") set -- "$1" "$?" '"$1"'=${'"$1"'%.} return "$2"' } get_whole_output whole_output cmd and its args (bearing in mind that there aren't many characters beside . that you can use safely there as it's important its encoding can't be found in the encoding of other characters. -- Stephane