🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Thomas M. Breuel Fri, 08 Sep 1989 08:54
exportable functions
#557
Author: Thomas M. Breuel
Date: Fri, 08 Sep 1989 08:54
6 lines
601 bytes
It would be nice if Bash supported exportable functions like V9 "sh".
Strings of the form "name=value" in the environment are considered
environment variables, and strings of the form "name(){value}" are
considered environment functions.

					Thomas.
Re: exportable functions
#564
Author: Chet Ramey
Date: Fri, 08 Sep 1989 16:05
38 lines
1897 bytes
In article <8909080854.AA12325@rice-chex> tmb@AI.MIT.EDU (Thomas M. Breuel) writes:

(Don't you love how the AI lab named all of their machines after breakfast
cereals? :-)

>It would be nice if Bash supported exportable functions like V9 "sh".
>Strings of the form "name=value" in the environment are considered
>environment variables, and strings of the form "name(){value}" are
>considered environment functions.

Funny, Doug Gwyn and I were having a discussion about this just last
weekend on comp.unix.questions.

The problem with the v9 syntax for exportable functions is that it requires
a C library `getenv()' that ignores the definitions and shells that
understand them (for example, this would choke a "regular" System V /bin/sh
started under bash -- either you would have some very strangely-named shell
variables, or the shell would just get all confused).

Bash does have exportable functions; the syntax is "name=() {value}", which
I think is a nice compromise:

kiwi$ echo $BASH_VERSION
1.03.59
kiwi$ type foo
foo is a function
foo () { echo this is foo }
kiwi$ export foo
kiwi$ bash
kiwi$ foo
this is foo
kiwi$

Chet Ramey
Chet Ramey			"We are preparing to think about contemplating 
Network Services Group, CWRU	 preliminary work on plans to develop a
chet@cwjcc.INS.CWRU.Edu		 schedule for producing the 10th Edition of 
				 the Unix Programmers Manual." -- Andrew Hume
exportable functions
#566
Author: Brian Fox
Date: Fri, 08 Sep 1989 16:21
25 lines
1231 bytes
   From: tmb@ai.mit.edu (Thomas M. Breuel)
   Date: Fri, 8 Sep 89 04:54:05 EDT

   It would be nice if Bash supported exportable functions like V9 "sh".
   Strings of the form "name=value" in the environment are considered
   environment variables, and strings of the form "name(){value}" are
   considered environment functions.

Bash 1.03 can export functions to other bashes.

Upon reading in the environment, if a string of the form "name=() {" is
found, then that is a function definition.  Perhaps I can support the
other syntax as well.

toplevel$ foo () { echo bar }
toplevel$ export foo
toplevel$ printenv foo
foo=() { echo bar }
toplevel$ bash
bash$ type foo
foo is a function
foo () { echo bar }

Brian Fox
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads