comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Strange UNIX or strange IDL?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Strange UNIX or strange IDL? [message #13344] Mon, 09 November 1998 00:00 Go to previous message
Vap User is currently offline  Vap User
Messages: 31
Registered: April 1998
Member
LC's No-Spam Newsreading account <nospam@ifctr.mi.cnr.it> writes:


> On 6 Nov 1998, Vap User wrote:
>
>> Harald Frey <hfrey@ssl.berkeley.edu> writes:
>>
>> returns a null string if there there isn't. PWD is always defined in
>> the Cshell (not sure about sh, but I think it must be true for it as
>
> not in mine (DU 3.2)
>
>> 'pwd' is a *command* in the cshell that returns the *value* of the
>> environmental variable 'PWD'. 'PWD' is not any command -unless you are
>
> Yes, pwd is the command, but the variable is called 'cwd'.
> pwd is the same as "echo $cwd"
> And 'cwd' is a shell variable (in csh use command "set" to see them)
> and not an environment variable (in chs use "printenv"). And since
> is not in the environment (of the parent process of IDL) IDL won't getenv
> it.

Actually, in the cshell, the PWD environmental variable is updated
everytime the cwd shell variable changes. See 'setenv' in
csh(1). However, this information doesn't help us in our current
problem, although I thought it did, until a short while ago.

> And also remember that within IDL you can CD to a different directory
> without any effect on the shell.
>
But not without effect on where files get written, for instance.

> So consider the two (IDL and shell)
> fully disjoint environments.
>


Boy, am I glad I messed around with this for a moment or two. I was
about to shoot myself in the foot, bigtime.

I think I have a handle on this now. It turns out that neither of us
are completely right, though Harald had a more *functionally*
complete understanding that I. I don't think it has anything to do
with which shell you're using or the way shells keep track of
PWD.. Since IDL is a compiled program, and is exec'd (if not
fork/exec'd) it has to keep track of the current working directory,
defined in my 'C A Reference Manual' as the directory where default
output will occur, and it does this. It even makes this information
available via 'cd,cur=cur & print,cur' should we want it. It just
doesn't update the PWD environmental variable, the way you can in
Perl when using the 'chdir' of the 'Cwd' module.

This problem arrises because PWD is the one of the few, if not the
only, environmental variables that are mutable over short time spans,
unlike say, USER.

While it is useful to have a handle on how environmental variables
are affected while in IDL, since this discussion started with the
question of how to get the current working directory, the best
suggestion remains...

pro pwd
cd,cur=cur & print,cur
end

This should work whatever the machine, whatever the shell.



whd





> --
> ------------------------------------------------------------ ----------
> nospam@ifctr.mi.cnr.it is a newsreading account used by more persons to
> avoid unwanted spam. Any mail returning to this address will be rejected.
> Users can disclose their e-mail address in the article if they wish so.
>

--
I don't speak for JPL, it doesn't speak for me.
Well, not all the time, at least.
William Daffer <vapuser@haifung.jpl.nasa.gov>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: random numbers with gamma distribution
Next Topic: Converting characters to real

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 15:27:22 PDT 2025

Total time taken to generate the page: 0.79406 seconds