zsh-workers
 help / color / mirror / code / Atom feed
From: "Mark Hessling" <m.hessling@qut.edu.au>
To: zsh-workers@sunsite.dk
Subject: Re: How to change environment from a module
Date: Sun, 29 Dec 2002 19:32:40 +1000	[thread overview]
Message-ID: <3e0ec138.10c34e.5239@imap.qut.edu.au> (raw)

> On Dec 22,  3:24pm, Mark Hessling wrote:
> }
> } So, from within the module I have, I need to be able to do the
> following: } 1) Get the current value of an environment variable
> } 2) Set the value of an enviornment variable
> } 3) Get the value of the current working directory
> } 4) Set the value of the current working directory
> } 
> } I thought I might be able to use bin_cd() and bin_typeset()
> 
> 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 ? See below for more
explanation.

> 
> } 2) How does one get the values of an environment variable and
> current } working directory from within a module ?
> 
> Most likely you want these functions:
> 
>     createparam(variablename, PM_EXPORTED);
>     getsparam(variablename);
>     setsparam(variablename, valuestring);
> 
>     struct dirsave ds;
>     dir = zgetdir(&ds);
>     restoredir(&ds);
> 
> It's very likely that your module should call zgetdir(&ds) before
> running the Rexx program and call restoredir(&ds) after it.  That
> is, the Rexx program should not permanently change the shell's
> current directory. Within the Rexx program, the usual chdir()
> system call can be used (but the values of the PWD and OLDPWD
> variables cannot be relied upon).  In this sense the Rexx program
> would behave as if it is an external command.

But this is the only reason for running a Rexx interpreter within the
current process of the shell; to change the environment permanently.

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. It seems that only a call to bin_cd() will result in a
call to chpwd().

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 ?

Cheers, Mark.

> 
> -- 
> Bart Schaefer                                 Brass Lantern
> Enterprises http://www.well.com/user/barts             
> http://www.brasslantern.com
> 
> Zsh: http://www.zsh.org | PHPerl Project:
> http://phperl.sourceforge.net


             reply	other threads:[~2002-12-29  9:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-29  9:32 Mark Hessling [this message]
2002-12-29 19:23 ` Bart Schaefer
  -- 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=3e0ec138.10c34e.5239@imap.qut.edu.au \
    --to=m.hessling@qut.edu.au \
    --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).