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 31387 invoked from network); 1 Feb 2021 16:14:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Feb 2021 16:14:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1612196066; b=Vxvl5iOpMUGbYJrAzUpI22V/E22lAjQZ8++V3h1l4DxW9umnlwPrY2lbccbl6brcsIbkHUfYKN QglpPz//cVURepUnI57CNVnulQSEKXQsRlRtGCH9b73HxVuw8chAVOGRyoUY55A2HSxYOr5tu0 92H/5mepG/b9rYoPksZ9hdcZmp4Sg2kYD6ceKrs8JDfTjG6iU5mmkTe5hvooTddSZujKIx3dL3 W00dDr30j0IEcrhy2JGnXaTYeaX1JBYfquNWR11f58cRLKcME8MWfDUm12DqYEdO6n/PTz9vu+ wzjfPBOYIQK70wtDX97/yiM7o6T+QZ7OkVlJ21SLATZemA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.25; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1612196066; bh=Ue/IiI4qXcqFCXA9mt7HaBEB1wAJH9NgMwNpM0+/vuE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=A7Y55HIi8HumGmSUTftpqFaHPoX5LJR4EKQjlhwId4RRSjiL1CX6oGholClJPoniG9rXnMb6Lw kDBZyIWxgf/puxDDYKoUp+smiwBA0knWnHVAadSRfkavr1f4gf7Db0dkB5DwYWVBaI+l4L5BqE zKHlm9xtEnIhZaK1we7vu5ZLW9hcj1SVBBXTQRu4Wzmi/q/oKpqrhllsnqYwe9SeeUffrJ46Nc 2SYn8reQwHhRW3LkKfptXiXkBIpc4PbqjSsDraom4xEvMhAWsDFTp5EDlk6vxs1rB7Gb+c4WcH T9tk2bYw9A+LjtI4kkuIxiDwdBvoqpvlYZRkx7IERxflsA==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=doi9KcFtcwtEs2yuRJSwPnHkOAYe7xC83p9rBEZivfc=; b=LQA29DxYhbjq3rW8yP02Yw/D1Q e8MBzlyf7/3/XJWK7fSKcObzAIW6gmJSKZYfrqwhT2HhoSd947UuOTfnriFl/LSpspDqCGWKu6Y5Z 4ssnwnAYLIsBDHt3O+EUMT+TFj63km3QOskuo5wvQ9ydQ5cv9N9sIEoJaCWNzo6XS+0wHDaHYtG+G HxsIqIFlneT1KYQTp9TzGi4+M9UCX4NIu6YpbmddRLh0Bu4BUuKPKWwg8fiw5VGickn9LFWGROss8 vt/6RlidFfuDvyB9EWxfWyLc4DAlp5HUUCGfjF9rNQlEJb8QYD8ql1Ztxix+LA/eGqtxE81ymFapM S7blJdSg==; Received: from authenticated user by zero.zsh.org with local id 1l6bqI-000EU6-HD; Mon, 01 Feb 2021 16:14:22 +0000 Authentication-Results: zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.25; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out1-smtp.messagingengine.com ([66.111.4.25]:57435) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1l6bpv-000EKE-67; Mon, 01 Feb 2021 16:13:59 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5E6AB5C0167; Mon, 1 Feb 2021 11:13:58 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 01 Feb 2021 11:13:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id:references :mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm2; bh=doi9KcFtcwtEs2yuRJSwPnHkOAYe7xC83p9rBEZi vfc=; b=kKLJ3PAxk2oA330lIpyc9Xxd6RjGflrpVLdJSvY+GnRCxQ7b0V7PLdIR qE0m1piWtbmvWjOGeD9jtGxAqExRAvfhYZsb7reu7Vydno+1PoF3ClmI8QmTdcAG BJeWenpFcDWuLXLuKDDshmTmxqkG/JRzix3ybG7RMtpA1iWAT6j5crdeXdRCEvoW wL80DVBCGPttRNyGQ/NRkyem7pA/K4Wm0hBDAnR0Tl1ZDwNMr3PKS82DkZt0ho8o Xb+DWUctxWb2E81/NnRKYEHjlcuD6CSjfMBAhbcnPZkdwRNtvuA61yUNO0n5bUP+ JiIjYOM8JrRcyNWjinDZJdnhSVVCsA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=doi9KcFtcwtEs2yuRJSwPnHkOAYe7xC83p9rBEZiv fc=; b=lVo0OuM8oKKIjpJ63gpuO8zuVncg4UoYQLAPCoMcrR9r8ZGbn/z+AjY2h Lsq9NWJyKCAIyw0BXMJAUJHKU/Sw088doImhPImvpAtMsS1bVXtdki53M1tD6oZ9 TvWW8kJBmmZEEpeLlTIISYN/l3pOrtmSCCZ8yNJm2A6c6nV65ufPsHeZsMuGX2gn tvHnB3RRsAXKX2FMSqyG2502Y1JCgU9ASXzzCNir3H6+6qLkvfXODM+v75h57cnF afYH5Da6YbKUTxmufBzAvrelo8eYYwx9IbPQ7x0dYXDLvS3GaksSwIcuLPMcyEwt sgWCO3A/c59RrmVO4v5umJCGL1viQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeekgdekhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtugfgjggfsehtke dttddtredunecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefgleehtdffuefhge euleefffejgedttdelhedvvdeuiefhvefgvdfghfevvdekteenucfkphepjeelrddujeek rddvkedrieefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-178-28-63.red.bezeqint.net [79.178.28.63]) by mail.messagingengine.com (Postfix) with ESMTPA id CEC7A24005B for ; Mon, 1 Feb 2021 11:13:57 -0500 (EST) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4DTtKw0k2yz3qj; Mon, 1 Feb 2021 16:13:56 +0000 (UTC) Date: Mon, 1 Feb 2021 16:13:56 +0000 From: Daniel Shahaf To: Zsh hackers list Subject: Re: [PATCH] FAQ update for aliasing Message-ID: <20210201161356.GB24303@tarpaulin.shahaf.local2> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 47896 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: Archived-At: Bart Schaefer wrote on Fri, Jan 29, 2021 at 11:35:28 -0800: > The section on csh-to-zsh alias equivalence had a number of > not-incorrect but not-up-to-date references. Attached patch fixes > these. > > However, when I do "cd Etc; make FAQ" on Ubuntu 20.04.1 LTS, I get > some strange formatting. Hopefully you can see what I mean in the > copy-paste below despite possible gmail line wrap: > > --- 8< --- > Here is Bart Schaefer's guide to converting csh aliases for zsh. > > > 1. ) If the csh alias references "parameters" (\!:1, \!* etc.), > then in zsh you need a function (referencing $1, $* etc.). > In recent versions of zsh this can be done by defining an anonymous > function within the alias. Otherwise, a simple zsh alias suffices. > > 2. ) If you use a zsh function, you need to refer _at_least_ to > $* in the body (inside the { }). Parameters don't magically > appear inside the { } the way they get appended to an alias. > --- 8< --- > > That is, most paragraphs get a hanging left indent (outdent?), but not > all do. This happens in other sections, not just the one touched in > the patch. I'm not sure the hanging leader is even intentional. Do > others see this? You mean the additional indentation of the "1."? I see it both with and without the patch: [[[ --- Etc/FAQ.unpatched +++ Etc/FAQ.patched @@ -640,21 +640,22 @@ (which converts your home directory to a ~). In fact, this problem is better solved by defining the special function chpwd() (see the manual). Note also that the `;' at the end of the function is optional in zsh, but not in ksh or sh (for sh's where it exists). Here is Bart Schaefer's guide to converting csh aliases for zsh. 1. ) If the csh alias references "parameters" (\!:1, \!* etc.), then in zsh you need a function (referencing $1, $* etc.). - Otherwise, you can use a zsh alias. + In recent versions of zsh this can be done by defining an anonymous + function within the alias. Otherwise, a simple zsh alias suffices. 2. ) If you use a zsh function, you need to refer _at_least_ to $* in the body (inside the { }). Parameters don't magically appear inside the { } the way they get appended to an alias. 3. ) If the csh alias references its own name (alias rm "rm -i"), then in a zsh function you need the "command" or "builtin" keyword (function rm() { command rm -i "$@" }), but in a zsh alias you don't (alias rm="rm -i"). @@ -683,44 +684,43 @@ \!^- $*[1,$#-1] \!*:q "$@" \!*:x $=* ($*:x doesn't work (yet)) 6. ) Remember that it is NOT a syntax error in a zsh function to refer to a position ($1, $2, etc.) greater than the number of parameters. (E.g., in a csh alias, a reference to \!:5 will cause an error if 4 or fewer arguments are given; in a zsh function, $5 is the empty string if there are 4 or fewer - parameters.) + parameters. Force an error in this example by using ${5?}.) 7. ) To begin a zsh alias with a - (dash, hyphen) character, use `alias --': csh zsh =============== ================== alias - "fg %-" alias -- -="fg %-" 8. ) Stay away from `alias -g' in zsh until you REALLY know what you're doing. There is one other serious problem with aliases: consider alias l='/bin/ls -F' l() { /bin/ls -la "$@" | more } `l' in the function definition is in command position and is expanded as an alias, defining `/bin/ls' and `-F' as functions which call - `/bin/ls', which gets a bit recursive. This can be avoided if you use - `function' to define a function, which doesn't expand aliases. It is - possible to argue for extra warnings somewhere in this mess. + `/bin/ls', which gets a bit recursive. Recent versions of zsh treat + this as an error, but older versions silently create the functions. One workaround for this is to use the "function" keyword instead: alias l='/bin/ls -F' function l { /bin/ls -la "$@" | more } The `l' after `function' is not expanded. Note you don't need the `()' in this case, although it's harmless. You need to be careful if you are defining a function with multiple ]]] Adding a blank line between «enumeration(» and «myeit()» fixes it: [[[ --- Etc/FAQ.unpatched +++ Etc/FAQ.patched @@ -637,22 +637,21 @@ cd() { builtin cd "$@"; print -D $PWD; } (which converts your home directory to a ~). In fact, this problem is better solved by defining the special function chpwd() (see the manual). Note also that the `;' at the end of the function is optional in zsh, but not in ksh or sh (for sh's where it exists). Here is Bart Schaefer's guide to converting csh aliases for zsh. - - 1. ) If the csh alias references "parameters" (\!:1, \!* etc.), +1. ) If the csh alias references "parameters" (\!:1, \!* etc.), then in zsh you need a function (referencing $1, $* etc.). Otherwise, you can use a zsh alias. 2. ) If you use a zsh function, you need to refer _at_least_ to $* in the body (inside the { }). Parameters don't magically appear inside the { } the way they get appended to an alias. 3. ) If the csh alias references its own name (alias rm "rm -i"), then in a zsh function you need the "command" or "builtin" keyword (function rm() { command rm -i "$@" }), but in a zsh alias ]]]