zsh-users
 help / color / mirror / code / Atom feed
* Lukasz Stelmach: question about functions in zsh
@ 2003-02-25 23:04 Peter Stephenson
  2003-02-26  7:36 ` Borzenkov Andrey
  2003-02-26 18:38 ` Pavol Juhas
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Stephenson @ 2003-02-25 23:04 UTC (permalink / raw)
  To: Zsh users list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1067 bytes --]


------- Forwarded Message

Date: Tue, 18 Feb 2003 15:24:34 +0100
From: Lukasz Stelmach <Lukasz.Stelmach@k.telmark.waw.pl>
To: coordinator@zsh.org
Subject: question about functions in zsh
Message-ID: <20030218142434.GA2376@tygrys.home.astercity.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
User-Agent: Mutt/1.4i
X-Mail-Editor: nvi

Greetings!!!

First of all, I have searched the documentation and I haven't found
the answer so I write to you.

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.

Have nice day...
- -- 
|/       |_,  _   .-  --,  Ju¿ z ka¿dej strony pe³zn±, potworne rz±dze
|__ |_|. | \ |_|. ._' /_.         Bêdê uprawia³ nierz±d, za pieni±ze


------- End of Forwarded Message


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Lukasz Stelmach: question about functions in zsh
  2003-02-25 23:04 Lukasz Stelmach: question about functions in zsh Peter Stephenson
@ 2003-02-26  7:36 ` Borzenkov Andrey
  2003-02-26 18:38 ` Pavol Juhas
  1 sibling, 0 replies; 3+ messages in thread
From: Borzenkov Andrey @ 2003-02-26  7:36 UTC (permalink / raw)
  To: 'Zsh users list'

 
> Greetings!!!
> 
> First of all, I have searched the documentation and I haven't found
> the answer so I write to you.
> 
> 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.
> 

There is no way. The problem is, environment is just a list of flat
var=value 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Lukasz Stelmach: question about functions in zsh
  2003-02-25 23:04 Lukasz Stelmach: question about functions in zsh Peter Stephenson
  2003-02-26  7:36 ` Borzenkov Andrey
@ 2003-02-26 18:38 ` Pavol Juhas
  1 sibling, 0 replies; 3+ messages in thread
From: Pavol Juhas @ 2003-02-26 18:38 UTC (permalink / raw)
  To: Zsh users list

On Tue, Feb 25, 2003 at 11:04:37PM +0000, Peter Stephenson wrote:
> 
> ------- Forwarded Message
> 
> Date: Tue, 18 Feb 2003 15:24:34 +0100
> From: Lukasz Stelmach <Lukasz.Stelmach@k.telmark.waw.pl>
> Subject: question about functions in zsh
>
> 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.

You can define your function in /etc/zshenv, then it should be
available to all zsh processes.

Pavol


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-02-26 18:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-25 23:04 Lukasz Stelmach: question about functions in zsh Peter Stephenson
2003-02-26  7:36 ` Borzenkov Andrey
2003-02-26 18:38 ` Pavol Juhas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).