Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!kiwi!chet From: chet@kiwi.CWRU.EDU (Chet Ramey) Newsgroups: comp.unix.questions Subject: Re: ENV file in ksh: is this smart? legal? Keywords: ksh, ENV, bash Message-ID: <526@cwjcc.CWRU.Edu> Date: 2 Sep 89 19:07:56 GMT References: <716@rodan.acs.syr.edu> <10890@smoke.BRL.MIL> Sender: news@cwjcc.CWRU.Edu Reply-To: chet@kiwi.INS.CWRU.Edu (Chet Ramey) Organization: CWRU Information and Network Services Lines: 32 In article <716@rodan.acs.syr.edu> Jerry Peek complains about ksh sourcing the $ENV file for all invocations of shell scripts, interactive or not. Doug Gwyn replies: >That's a Korn shell design botch. Apparently DGK thought that the C shell >behavior should be mimicked. Too bad he didn't first notice what a pain >it already was for C shell users. When Doug Kingston and I added a >similar feature to the BRL Bourne shell, we were more careful, and I think >ours works right. It does NOT get sourced for shell scripts (unless they >decide to source the file themselves, which would be exceedingly rare). I think there might be an additional reason Korn did it that way: because the Korn Shell does not provide exportable shell functions. Using ksh, the only way to have your personal shell functions (which are assumed to be defined in the $ENV file) available when executing a script is to source the $ENV file for every ksh invocation. (The BRL Bourne Shell doesn't let you export functions to a sub-shell either, so its users have the same problem.) You could argue that shell scripts that want or need these functions should source the necessary files themselves (and I would agree with you), but maybe Korn thought otherwise when he put the feature into ksh. (I can't resist a plug). In BASH, the Gnu Bourne-Again SHell, functions are exportable. Version 1.03 was just released, grab it from prep.ai.mit.edu. Chet Ramey (a bash contributor) 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