From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23794 invoked from network); 30 Aug 2005 01:35:10 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Aug 2005 01:35:10 -0000 Received: (qmail 57597 invoked from network); 30 Aug 2005 01:35:03 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Aug 2005 01:35:03 -0000 Received: (qmail 17110 invoked by alias); 30 Aug 2005 01:35:00 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21690 Received: (qmail 15031 invoked from network); 30 Aug 2005 01:08:19 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 Aug 2005 01:08:19 -0000 Received: (qmail 41657 invoked from network); 30 Aug 2005 01:08:19 -0000 Received: from hex.databits.net (216.118.117.77) by a.mx.sunsite.dk with SMTP; 30 Aug 2005 01:08:15 -0000 Received: from hex.databits.net (localhost.databits.net [127.0.0.1]) by hex.databits.net (Postfix) with ESMTP id BEF5357B2D for ; Mon, 29 Aug 2005 20:08:13 -0500 (CDT) From: Pete Fritchman To: zsh-workers@sunsite.dk Subject: bug with aliases and declaring functions Date: Mon, 29 Aug 2005 18:08:13 -0700 Sender: petef@hex.databits.net Message-Id: <20050830010813.BEF5357B2D@hex.databits.net> X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.0.4 Hi, $ alias foo='echo test|sort' $ foo() { echo func; } $ sort func $ If instead you declare the function with the function keyword, i.e. function foo() { echo func; } expected behavior occurs. So, my theory is that the zsh parser is re-writing 'foo() { echo func; }' to 'foo () { echo func; }' and then 'foo ' is seen at the beginning of the command, and foo's alias is substituted. This is also a useful test to see what's happening: $ alias foo='echo test|sort' $ set -x $ foo() { echo func; } +-/bin/zsh:5> echo test $ foo () { echo func; } +-/bin/zsh:6> echo test $ set +x $ declare -f [...] sort () { echo func } $ If this difference in behavior between 'foo() { ... }' and 'function foo() { ... }' is expected, I think it should be documented somewhere. Of course, I think this is a bug and should probably be fixed :-) BTW, as a data point: the same thing happens in bash. thanks, -- petef