Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!ucbcad!ucbvax!decvax!decwrl!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: Korn Shell Message-ID: <15224@sun.uucp> Date: Wed, 18-Mar-87 00:56:47 EST Article-I.D.: sun.15224 Posted: Wed Mar 18 00:56:47 1987 Date-Received: Thu, 19-Mar-87 06:41:24 EST References: <580@csun.UUCP> <5680@brl-smoke.ARPA> <2201@ptsfa.UUCP> <730@hoqax.UUCP> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Organization: Sun Microsystems, Mountain View Lines: 26 Keywords: Korn shell ksh aliases parameters >Why can't aliases and functions be exported like shell variables? The UNIX environment mechanism doesn't know about aliases and functions. The low-level mechanism only knows about strings; the user-mode code (in the shells, and in "getenv" and "putenv") knows about strings of the form "=". You'd have to come up with some convention to distinguish exported variables and aliases from exported variables. You would not be able to have an equals sign *anywhere* in the alias or function, because the "getenv" code is very simple-minded and would see any string containing an equals sign as a "=" item. Also, since the environment is treated just like a second argument list, it is subject to the same size limitations as argument lists. This means, on most machines, no more than 5120 or 10240 or 20480 (depending on your flavor of UNIX) characters in your argument and environment lists combined. My .kshrc is 4190 bytes; even if half of them are comments, this is still a significant fraction of 5120. If you get *really* fancy, you can push this limit - and remember, this is a limit on the total size of environment variables *and* arguments, so the bigger your environment gets, the smaller the maximum number of arguments you can pass to a program gets. It also takes time to copy a big environment when doing an "exec" - and this time is spent on *every* "exec", regardless of whether it'll use the values in the environment or not.