From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14294 invoked from network); 31 Dec 2002 01:17:06 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 31 Dec 2002 01:17:06 -0000 Received: (qmail 342 invoked by alias); 31 Dec 2002 01:17:00 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18039 Received: (qmail 334 invoked from network); 31 Dec 2002 01:16:59 -0000 Sender: m.hessling@qut.edu.au From: "Mark Hessling" Reply-to: m.hessling@qut.edu.au To: zsh-workers@sunsite.dk Subject: Re: How to change environment from a module X-Mailer: Quality Web Email v3.0q, http://netwinsite.com/refw.htm X-Originating-IP: 131.181.143.119 Date: Tue, 31 Dec 2002 11:16:53 +1000 Priority: normal Message-id: <3e10f005.e655a.15727@imap.qut.edu.au> > On Dec 29, 7:32pm, Mark Hessling wrote: > } > } [Bart wrote:] > } > In general you shouldn't call bin_ functions directly. They > } > should almost always be called only via the command execution > } > code. > } > } Why should these functions not be called directly ? > > Because they often depend on the generic command setup that is > performed in the execution code in exec.c. Fair enough. > > } > It's very likely that your module should call zgetdir(&ds) > before } > running the Rexx program and call restoredir(&ds) > after it. } > } But this is the only reason for running a Rexx interpreter > within the } current process of the shell; to change the > environment permanently. > > I can think of other reasons, such as avoiding the overhead of > repeated forks and of reloading the interpreter. Yes, but they are not the primary practical reasons from a user's perspective; particularly one from an OS/2 background where the Rexx interpreter there is an integral part of the shell. Its this behaviour I'm trying to duplicate with zsh. > > } Based on this premise, then calling routines like zchdir() > doesn't } go the whole way. ie if you have a chpwd() function in > zshrc, then } zchdir() doesn't call it. > > That's true -- zchdir() is a function meant to be called by the > zsh internals at a lower level than the command interpreter. > > } So again, how should one call the bin_*() functions directly > from a } module as though a "cd" command or "export" command were > executed } directly by the user ? > > This is akin to asking how to attach a clutch pedal to an > autmobile with an automatic transmission. Just because there's a > clutch plate in there somewhere doesn't mean there's an easy way > to bolt new a lever to it. In fact, you're trying to connect an > entire second engine to the drive chain, and wondering why the > chassis wasn't designed for that. > > The best suggestion I can give you is: > > sprintf(command, "\\builtin cd %s", bslashquote(dirname, NULL > , 0)); > execstring(command, 1, 0); > > Where it's up to you to be sure that the command buffer is large > enough. Crude but very effective :-) Works like a charm! Also did the same with "\\builtin export %s=%s", and it also works exactly how I wanted. Many thanks Bart for your suggestions, the module works great. One last question; naming standards for modules. Are third-party modules allowed to start with "z" ? eg. I've called mine "zregina", so that the "regina" executable will still be available as an external program. Cheers, Mark.