From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15616 invoked from network); 26 Feb 2003 07:37:07 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 26 Feb 2003 07:37:07 -0000 Received: (qmail 6113 invoked by alias); 26 Feb 2003 07:36:35 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5944 Received: (qmail 6102 invoked from network); 26 Feb 2003 07:36:34 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 26 Feb 2003 07:36:34 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [192.35.17.2] by sunsite.dk (MessageWall 1.0.8) with SMTP; 26 Feb 2003 7:36:34 -0000 Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.11.6/8.11.6) with ESMTP id h1Q7aYX22064 for ; Wed, 26 Feb 2003 08:36:34 +0100 (MET) Received: from MOWD019A.mow.siemens.ru ([163.242.196.119]) by mail3.siemens.de (8.11.6/8.11.6) with ESMTP id h1Q7aXa24612 for ; Wed, 26 Feb 2003 08:36:33 +0100 (MET) Received: by mowd019a.mow.siemens.ru with Internet Mail Service (5.5.2653.19) id ; Wed, 26 Feb 2003 10:38:25 +0300 Received: from mw2b210c (163.242.193.12 [163.242.193.12]) by MOWD019A.mow.siemens.ru with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id FVCJ6PYW; Wed, 26 Feb 2003 10:38:23 +0300 From: Borzenkov Andrey To: "'Zsh users list'" Subject: RE: Lukasz Stelmach: question about functions in zsh Date: Wed, 26 Feb 2003 10:36:27 +0300 Message-ID: <6134254DE87BD411908B00A0C99B044F03A0B646@mowd019a.mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 In-Reply-To: <20030225230442.CD1561B76B@pwstephenson.fsnet.co.uk> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 =20 > Greetings!!! >=20 > First of all, I have searched the documentation and I haven't found > the answer so I write to you. >=20 > Is there any way in zsh to make a function declared with "function > name() {..." syntax a global one? That is exported to environment > of child processes of zsh which means also other instances of zsh. > I would like to define a function in /etc/zlogin or zprofile (a = *login* > scrpit) and not in zshrc and make it defined for all subprocesses. >=20 There is no way. The problem is, environment is just a list of flat var=3Dvalue string. There is no way to mark "var" as being a function = as opposed to plain variable (the same problem with "exporting" arrays BTW = ...) Shells that do support it (I guess bash, anyone else?) introduce a hack = - they parse environment and if a value _looks_ like a function = definition they basically eval it. First, it is a hack. It prevents legitimate variable assignment. = Second, it opens up the whole new can of worms w.r.t. security ... functions take precedence over external commands so consider a hacker redefining = /bin/grep and calling suid program ... and there is no way to easily filter such function definition as opposed to well known variables like = LD_LIBRARY_PATH & co. Could you show the situation when you do need exporting functions? = Frankly speaking I cannot think of a case when it is needed (and cannot be = solved just as easily in other way). -andrey