From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2047 invoked from network); 21 Jul 2022 03:17:31 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Jul 2022 03:17:31 -0000 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:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=jyijmP81IbA/bCJC3V5Ce9c3NXilzDa2wCUFZWIHrd4=; b=bmNhaMGV08K4vCBwG4aGSJNmMK 5zCsXE7hzWihNMWbyMcdoScyUbNSey0UvvFiZiEFW8sIYzzq5KAwzfzhsbMrTR2Uxj2YjNTEpeGRd axUdJNx5KHz2pHUasVolfz4l4HrhTUhxiw501eG6lPKo0ADyH6oQtX8PaCI8W8oAwcQL8eHYE4Qr5 LD8W6wqspYS2/msA5S1yywVu5O5dxEIQjFYTHomVIuuoQXb6iO7w71fi0hqAUAjrqG/80iskRRgBi N2Buw2QRRHoF3hVNbQPixN+OSR/TxEZjc/LgGnhe1CFeopxctDkBFVIlWYy7XArbI/rrP5dQK25WW He2TG2QQ==; Received: from authenticated user by zero.zsh.org with local id 1oEMgs-000Gq9-GC; Thu, 21 Jul 2022 03:17:30 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oEMfL-000G91-Al; Thu, 21 Jul 2022 03:15:55 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id ABE3727C0054; Wed, 20 Jul 2022 23:15:53 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Wed, 20 Jul 2022 23:15:53 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudelfedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvvefutgfgse htqhertderreejnecuhfhrohhmpefnrgifrhgvnhgtvggpgggvlhojiihquhgviicuoehl rghrrhihvhesiihshhdrohhrgheqnecuggftrfgrthhtvghrnhepffehvdelvdeihffhvd ejffeitdeuvdetjefhuedufeetgeetgeegjedtgfeffedunecuffhomhgrihhnpehsohhu rhgtvghfohhrghgvrdhiohenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihvhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihht hidqudduhedukeejjedtgedqudduledvjeefkeehqdhlrghrrhihvheppeiishhhrdhorh hgsehfrghsthhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 619E831A0062; Wed, 20 Jul 2022 23:15:53 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-755-g3e1da8b93f-fm-20220708.002-g3e1da8b9 Mime-Version: 1.0 Message-Id: <9fb183bb-8478-4eea-b543-124fb2181f10@www.fastmail.com> In-Reply-To: <9310fc4a-8db9-48d8-873b-c50a63f9aea5@www.fastmail.com> References: <28c00da7-cfdd-4f58-a539-8deebbe5dfa5@www.fastmail.com> <645ba344-9d97-4ddf-82c6-e6338c98da8b@www.fastmail.com> <9310fc4a-8db9-48d8-873b-c50a63f9aea5@www.fastmail.com> Date: Wed, 20 Jul 2022 23:15:32 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: "Anthony Heading" Cc: zsh-users@zsh.org Subject: Re: view onto command pipeline? Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 27913 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Wed, Jul 20, 2022, at 10:11 PM, Anthony Heading wrote: > On Wed, Jul 20, 2022, at 9:35 PM, Lawrence Vel=C3=A1zquez wrote: >> Leaving $opts[@] unquoted still elides empty elements in this >> context; that behavior is not limited to $@. (If this is what you >> actually want, go for it. Just don't think that fiddling with >> options has an effect.) >> > > Yes indeed! Though recall the context here was a *fixed* *literal* ar= ray: > opts=3D(-c color.ui=3Dalways) > command git $opts "$@" > > Quoting "$@" agreed, but writing "${opts[@]}" instead here seems > a little bit like self-flagellation, no? Sure, it doesn't matter for this particular case. I didn't notice that you were hardcoding the array contents. >> It's better to run ''emulate -L zsh'' inside the function itself >> (or localize and [un]set options individually as desired) to achieve >> a known state, rather than relying on a specific method of invocation. > > Oh, interesting! why is that? Certainly want to get the most > stable state. I do vaguely remember tricky corner cases being discussed > on zsh-workers maybe decades ago, but it seems to work great now. > And, unless I picked up this autoload idiom from the mailing list, > I think it's from the man pages somewhere. If you're advising that > it's sub-optimal, should it be removed or caveated in the documentatio= n? I assume you're referring to this (https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html#inde= x-autoload): Note that the autoload command makes no attempt to ensure the shell options set during the loading or execution of the file have any particular value. For this, the emulate command can be used: emulate zsh -c 'autoload -Uz func' arranges that when func is loaded the shell is in native zsh emulation, and this emulation is also applied when func is run. I'm not saying there's anything incorrect here. I imagine it's useful if you're using functions written by others that break due to options you've set or unset in your own environment. What I'm saying is that if you are writing your own functions, you should try to write them so they proactively establish whatever state they require, instead of punting that responsibility to the caller. (This is just common sense.) If you need many options to have their zsh-native default values, then it generally suffices to call emulate -L zsh at the beginning of the function. --=20 vq