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 30803 invoked from network); 7 Apr 2021 12:59:28 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Apr 2021 12:59:28 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617800368; b=DxNRWEGXZvo7cnh7CLGR3Oqcm58r0V0pl/9rWByz/Gd3RetqLgblTSDoHFeJEiZXFfzruWHrqU gnaBGIO+aG0dDiPBNY6fZJ03IKj9dXe72tolaANex4rw5mJyo2JrbJWElZE4Fx05BXwjVNdL1w yhilF07C9Q/MNO8c8HTk3cpxSsEYxs6kwMsu4T+SWlq/p66QhPiiYHsPwwRsXd62q4K/1+BByz eilxsQdy42mSxaLYURVQKNUSwGkgAr0LpQugPioRGTnFxlyHnltVdFwBsO8sLImXsywb1wTXQr RWMmXMiHSyg4n+O4JUz4T2OJtjUc3WeFh495rpGHc5xKog==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1617800368; bh=dSwSUEo6I1juegHx8c46dGE76NyaB/+H0FOXGzAB40M=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=LF6ksqAhOqfNcHkBIgKa6YaCrDKq1FR8moSQYGHg482KKbgOYRraPRu/uAiu8Y2Kif1jvkAjlL CEIConACiyHBGRgk56YKN90SgHTcXH3nMVUnECOc3e3tYbtdNHm663bFn9ZZf1fXZkON/l+zny DPegDNRbpVfGdwvHHExKE07JUADRkW/KWlkSfM2DLI6pWZIxP9QrPc+22GzCVsrMxWLA0Frljd gqX0N9bGkV4zjmupDiFdBlj3KY1ihVkWtnshZlgn+qYooCIt7A1tZXHeQqh3PUpNJlsCEftx3z a7f1RQ/91g6vfQYXaI8HnYUP7vs+CqFqRnpL5WWNo8QQeA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=sj7cS7qT032b34fWcRO4SN/In50OB+Xzqie9sTf1lp8=; b=zQv25ILriGJcptH9gvv+S7dIBW cfVM+LvGjjJDeHrZRB62VKxOK7ULGztHEf5uDp8HZgpyq1BunhyozZteVMK9aV5yBfc7RYA8bW5LP x3wEXFzQuUtNIN6gnWsrjpo3qk+QPrpS3Vu7nBOMNtGCWIhC4BXlRb6/BXVOV2kRhdnNFWgUFAULs n6IvcapZ0TYpfZF46kze6XKKQj0MSLeIukzWmIIo7Z4dh2wF/FfUgf8bXCOLlr5CqzTXg4TcGi4vd DbKR0iWRSJNcpMcAy+jfOjv98XdW7zfNYlwnXAM6PzRIowD8D00/WRQTVCBYvVLDRRxAW6yIKMBeV ZvBjl5ZQ==; Received: from authenticated user by zero.zsh.org with local id 1lU7mJ-000FD7-Ar; Wed, 07 Apr 2021 12:59:27 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:55458) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1lU7l3-000Ed9-I0; Wed, 07 Apr 2021 12:58:10 +0000 Received: from [212.54.57.82] (helo=smtp3.tb.ukmail.iss.as9143.net) by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1lU7l2-0005e5-Q5 for zsh-users@zsh.org; Wed, 07 Apr 2021 14:58:08 +0200 Received: from oxbe3.tb.ukmail.iss.as9143.net ([172.25.160.134]) by smtp3.tb.ukmail.iss.as9143.net with ESMTP id U7l2lmlgziCtJU7l2lVqBs; Wed, 07 Apr 2021 14:58:08 +0200 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-users@zsh.org X-SourceIP: 172.25.160.134 X-CNFS-Analysis: v=2.4 cv=GushRm5C c=1 sm=1 tr=0 ts=606dac60 cx=a_exe a=rX2mKgs1IZJU9lF6pltyEQ==:117 a=ADWkfsjt5WoA:10 a=IkcTkHD0fZMA:10 a=ac2Zk7JPEtsA:10 a=tMb1h1NYAAAA:8 a=N898d1J4AAAA:8 a=vTx9ge9lO6q38W9D7h4A:9 a=QEXdDO2ut3YA:10 a=jaI_LXnIXFgJbRmOhuTi:22 a=4OhKILdWXy8MGewZJRtY:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1617800288; bh=dSwSUEo6I1juegHx8c46dGE76NyaB/+H0FOXGzAB40M=; h=Date:From:To:In-Reply-To:References:Subject; b=Sc7befovCfimQurhIxFqdKlVpLkY3Do9r9LwqSt7LxUwg+h92w0YQ0AvNOHyyisT7 oWZqYvMxT28OX5wx0civpSj3QRjHFFnUcCrBFVQ5aEdWMzH6yxrsYzRnSJ/dasMFVC CUHbn7b528FGkunUkQPoGFcPKLwQJg3qT6P2OmELTD+4fEga0lK2m5L37llLuJv0H5 7YiWfr68xTFYc62LOYJLnDLemg/i588f1mtmf6+h8gfdpZWkjP2wrfTDnofj5CL28r VwFahVFPzOREE3W8s3UlPshrSsaW3hXVjeCaSpuP6l7kTvkpk4s/PnaUi1NquDReTB e1zYO1l2Ap1ew== Date: Wed, 7 Apr 2021 13:58:08 +0100 (BST) From: Peter Stephenson To: zsh-users@zsh.org Message-ID: <1077600344.1098154.1617800288527@mail2.virginmedia.com> In-Reply-To: References: <20210407070518.szoet4rxbouwzelm@chazelas.org> Subject: Re: alias with a parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev72 X-Originating-IP: 147.161.167.116 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfIVbdUkxTZmOlRwtsGYXSvXkL9dMGPXXdu5s+BS2k9Qs8h0Lq4cNisjw8DmwUWmVXFTncwvTXsxrCRnjyRW06jmYassHMMMZMhEj35z1HqNUMP0TdKWw Ukb49LjtmFIqegjWeOHQAHPOwAs9SnzMbe+S+zj0XE2KY+sDQBkUX/KGMmsTOrCoPZrFbDtCgIvASc6HR2GlASmYtnonfireyO8GniAtu3JdHQvOEzVtjnZA X-Seq: 26632 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 07 April 2021 at 13:48 lb@covisp.net wrote: > > On 07 Apr 2021, at 01:05, Stephane Chazelas wrote: > > 2021-04-05 20:47:47 -0600, Grant Taylor: > > [...] > >> pd() { > >> [ -n "${1}" ] && pushd "${1}" || popd; > >> } > > > That function would run popd when pushd fails. It's generally a > > bad idea to use this kind of a && b || c in place of proper > > if/then/else constructs. > > Bad idea, or just a style "this is proper practice" sort of thing? > > I can't imagine any 'bad idea' from this, as it is doing the same basic thing. Stephane is pointing out that what you want is: if [[ -n $1 ]]; then pushd "$1" else popd fi but what you've got is (writing out in full for clarity): if [[ -n $1 ]]; then if ! pushd "$1"; then popd fi else popd fi because of the slightly obscure but nonetheless well-defined way && and || work. pws