delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/18/06:12:53

Date: Wed, 18 Dec 2002 13:11:50 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Jeremy W. Murphy" <jwm AT bud DOT cc DOT swin DOT edu DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: Which editor, and, install prob with tmp dir
In-Reply-To: <5.1.1.6.2.20021218174514.028a6ec0@bud.cc.swin.edu.au>
Message-ID: <Pine.SUN.3.91.1021218125721.8222D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

[Please keep this discussion on the news group, as I think it is useful 
for others to read it.]

On Wed, 18 Dec 2002, Jeremy W. Murphy wrote:

> Sorry, it's in .bashrc, not .bash_login:
> 
>    TMPDIR="${DJDIR}/tmp"
>    export CVSROOT EDITOR TMPDIR

So exporting is not the problem.

> Yup, when I unset SHELL, the result changes to:
> 
>    c:\djgpp\tmp
>    c:\djgpp\tmp/dj500000
>    system("dir c:\djgpp\tmp/dj500000")
>    dir: c\:/djgpp/tmp/dj500000: No such file or directory (ENOENT)
>          ^
> How do you explain the backslash there in "c\:/djgpp" ???

Since you have Fileutils installed, the `dir' you invoke here is still 
dir.exe from Fileutils.  (The DJGPP implementation of `system' looks 
along the PATH for any command first, and only if it doesn't find it, 
does it consider the possibility that the command is a shell built-in.
And I'm guessing that the backslash is not a real one: it's added by 
`dir.exe' for semi-cosmetic purposes, namely, if you want to pass the 
message printed by `dir.exe' to some Bash command, it's a good idea to 
escape the colon, since otherwise that other Bash command might fail.

If you want to invoke the command.com's `dir', try creating the command 
you pass to `system' like this:

  sprintf(buf, "command.com /c dir %s", n);

(Btw, the subtleties of the `system' operation are described in great 
detail in the DJGPP libc reference; I suggest to read that if you didn't 
already.)

Given that the issue of the backslash before the colon is understood, 
what problem(s) are left that you don't know how to solve?

> So what is the ideal environment setup regarding directory names?  To have 
> getenv() return them as forward- or back-slashed?

You should strive to have them forward-slashed if your SHELL variable 
points to Bash, back-slashed otherwise.

> I still don't know how 
> getenv() is turning an exported forward-slashed dir into a back-slashed 
> one!

I don't understand that fully, either yet.  One thing that isn't clear to 
me is whether, when you ran the program after unsetting SHELL, you ran it 
from inside Bash or from a normal DOS box.

Also, did you edit your djgpp.env file in any way, and if so, what 
changes did you make there?

> But evidently back-slashed dir names are incompatible with having 
> SHELL=bash.

That's very true.

> What does $TMPDIR, $SHELL and getenv("TMPDIR") return on your 
> system?

SHELL is not set, TMPDIR and getenv return what you expect (i.e. they 
don't convert slashes).  But that's from memory, I cannot actually check 
this where I'm typing this message.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019