From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: How to change environment from a module
Date: Sun, 29 Dec 2002 19:23:10 +0000 [thread overview]
Message-ID: <1021229192311.ZM23619@candle.brasslantern.com> (raw)
In-Reply-To: <3e0ec138.10c34e.5239@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.
} > 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.
} 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.
next prev parent reply other threads:[~2002-12-29 19:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-29 9:32 Mark Hessling
2002-12-29 19:23 ` Bart Schaefer [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-12-31 1:16 Mark Hessling
2002-12-31 1:39 ` Zefram
2002-12-22 5:24 Mark Hessling
2002-12-22 17:57 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1021229192311.ZM23619@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).