zsh-users
 help / color / mirror / code / Atom feed
From: Borzenkov Andrey <Andrey.Borzenkov@siemens.com>
To: "'Zsh users list'" <zsh-users@sunsite.dk>
Subject: RE: Lukasz Stelmach: question about functions in zsh
Date: Wed, 26 Feb 2003 10:36:27 +0300	[thread overview]
Message-ID: <6134254DE87BD411908B00A0C99B044F03A0B646@mowd019a.mow.siemens.ru> (raw)
In-Reply-To: <20030225230442.CD1561B76B@pwstephenson.fsnet.co.uk>

 
> 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


  reply	other threads:[~2003-02-26  7:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-25 23:04 Peter Stephenson
2003-02-26  7:36 ` Borzenkov Andrey [this message]
2003-02-26 18:38 ` Pavol Juhas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6134254DE87BD411908B00A0C99B044F03A0B646@mowd019a.mow.siemens.ru \
    --to=andrey.borzenkov@siemens.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).