9fans archive / 2000 / 11 / 44 /    prev next

From: "Douglas A. Gwyn" <gwyn@arl...>
Subject: Re: [9fans] usage of CPU server
Date: Fri, 3 Nov 2000 14:22:15 GMT

rob pike wrote:
> The one feature in that long list that is notably absent is the ability
> to export functions.

I have to say that I never felt the need for them.  The startup
file per interactive shell named by $ENV typically sources a
separate file in which a battery of useful functions are defined.
One constraint in many older UNIX systems is that the environment
has only a limited amount of space, and if there were a lot of
large function definitions in the environment it could easily
exceed the available space.

As a general design principle for anyone who does add function
definitions to the environment, the "env" command should print
them in a form that can be directly executed by the shell to
define the functions.  Also, exported environment variables
should be printed in a form that can be directly ditto.

$ env  # prints:
PATH=/bin:/usr/bin:~/bin export PATH
setenv(){ eval $1="'"$2"'" export $1; }
# etc.