Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!apollo!nazgul From: nazgul@apollo.COM (Kee Hinckley) Newsgroups: comp.sys.apollo Subject: Re: go to old directory == 'back' ?? Keywords: Aegis shell levels Message-ID: <443447ef.1b147@apollo.COM> Date: 3 Jul 89 19:43:00 GMT References: <678@idacom.UUCP> Reply-To: nazgul@apollo.COM (Kee Hinckley) Organization: Apollo Computer, Chelmsford, MA Lines: 58 In article <678@idacom.UUCP> danny@idacom.UUCP (Danny Wilson) writes: >I thought this would be a great function for the Aegis shell. I made >the following shell scripts: > >file: wd > eon > if eqs ^1 "" then > /com/wd # no parameters, just print where we are > return > endif > old := ^"/com/wd" > export old > /com/wd ^1 > >file: back > eon > back := ^old > old := ^"/com/wd" > /com/wd ^back > dlvar back > /com/wd > >However, because the variable 'old' gets set at a lower shell level it >is undefined within program 'back'. Has anyone got a solution for >a (seemingly) easy problem like this? First of all you should probably stop using /com/wd, and just use wd. wd is a builtin at SR10 (one program per process and all that). The version in /com is a shell script, so it will still work, it's just slower. Now for the problem. There is no way to have a shell script change a variable above it unless you "source" the shell script. To do what you want I think the best solution would be: wd: #!/com/sh eon if eqs ^1 "" then wd else wd > ^HOME/.olddir wd ^1 endif back: #!/com/sh eon read back < ^HOME/.olddir wd > ^HOME/.olddir wd ^back Note that I haven't tested this! -kee -- ### User Environment, Apollo Computer Inc. ### Public Access ProLine BBS ### ### {mit-eddie,yale}!apollo!nazgul ### nazgul@pro-angmar.cts.com ### ### nazgul@apollo.com ### (617) 641-3722 300/1200/2400 ### I'm not sure which upsets me more; that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's.