From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 499 invoked from network); 27 Mar 1997 19:14:27 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 27 Mar 1997 19:14:27 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id OAA11349; Thu, 27 Mar 1997 14:09:05 -0500 (EST) Resent-Date: Thu, 27 Mar 1997 14:09:05 -0500 (EST) From: Zefram Message-Id: <6837.199703271911@stone.dcs.warwick.ac.uk> Subject: Re: ksh autoloading To: roderick@argon.org (Roderick Schertler) Date: Thu, 27 Mar 1997 19:11:12 +0000 (GMT) Cc: zsh-workers@math.gatech.edu (Z Shell workers mailing list) In-Reply-To: <14594.859489039@eeyore.ibcinc.com> from "Roderick Schertler" at Mar 27, 97 01:57:19 pm X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]9088.99 X-Phase: The Moon is Waning Gibbous (88% of Full) X-US-Congress: Moronic fuckers X-Personality: INTJ X-This-is-not-HTML: Content-Type: text Resent-Message-ID: <"4ozBn.0.Dn2.GNiEp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3042 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Roderick Schertler wrote: >Well, of course, if the function is written knowing it could run under >ksh or zsh then it can be made to work. The problem is that a function >which was written in ksh style will suddenly stop working (on first >invocation). That used to be the case for *all* ksh style functions. With this patch in place, the most common case by far -- a single function with no initialisation code -- is handled properly. >I don't see how the zsh behavior is superior, and I do see advantages to >the ksh behavior. With zsh, you can have a file that is used both as an autoloaded shell function and as a shell script. It also makes it impossible to have an autoloaded shell function that, when successfully autoloaded, still isn't defined. >Consider a file which provides 3 tightly related functions and runs some >initialization code. I used such a think for directory stack handling >in ksh, eg. In ksh you link it to the 3 names. In zsh you have to do >some work. OK, use the line [[ -n "${ZSH_VERSION+set}" ]] && "$0" "$@" instead of what I previously suggested. >I wanted to be sure you knew you were breaking ksh compatibility. We never had complete ksh compatibility anyway. Perhaps we need an option to behave exactly like ksh here, i.e., just source the file before running the function. I look on the patch as improving zsh compatibility. It means that any function written in the zsh style (except for the one perverse case of a function that does nothing but redefine itself) will work as expected. -zefram