From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17762 invoked by alias); 12 Sep 2015 21:33:16 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20544 Received: (qmail 28346 invoked from network); 12 Sep 2015 21:33:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=jE+ovs97kTJM1dD6JNRapQ==:117 a=jE+ovs97kTJM1dD6JNRapQ==:17 a=IkcTkHD0fZMA:10 a=Am8Wlcz6U7MA7Du3kmkA:9 a=QEXdDO2ut3YA:10 Message-id: <55F4930A.40608@eastlink.ca> Date: Sat, 12 Sep 2015 14:03:06 -0700 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 To: zsh-users@zsh.org Subject: Re: Announce of Zsh Navigation Tools References: <55F465E6.1040405@eastlink.ca> <2125131442086868@web14o.yandex.ru> In-reply-to: <2125131442086868@web14o.yandex.ru> On 09/12/2015 12:41 PM, ZyX wrote: > They will work if located in *any* directory listed in $fpath. And they *are* functions, you need to read about autoload functions in man zshmisc, section AUTOLOADING FUNCTIONS: I see. So we very elegantly have it both ways--a script as it appears to be, but also as a function via autoload. > > If the KSH_AUTOLOAD option is set, or the file contains only a simple definition of the function, the file's contents will be executed. This will normally define the function in question, but may also per‐ > form initialization, which is executed in the context of the function execution, and may therefore define local parameters. It is an error if the function is not defined by loading the file. > > Otherwise, the function body (with no surrounding `funcname() {...}') is taken to be the complete contents of the file. This form allows the file to be used directly as an executable shell script. If pro‐ > cessing of the file results in the function being re-defined, the function itself is not re-executed. To force the shell to perform initialization and then call the function defined, the file should contain > initialization code (which will be executed then discarded) in addition to a complete function definition (which will be retained for subsequent calls to the function), and a call to the shell function, > including any arguments, at the end. That clarifies things greatly. I've had a vague wondering what autoload was, just took it on faith that it was important. What are the pros and cons of doing things that way vs. what might seem to be the more obvious function definition? It's more compact, but then requires the special calling via autoload. I expect there will be some substantial difference. >