Mail Archives: djgpp/2002/12/18/01:30:16
On 18 Dec 2002 065211 AT bud DOT cc DOT swin DOT edu DOT au wrote:
> : >Anyway, main query
> : >2. Why is getenv("TMPDIR") returning "c:\djgpp\tmp" (back slashes) when from
> : >bash, TMPDIR is definitely set with forward slashes? Thanks in advance
> : >for help on this one, it's driving me... buggy! :)
>
> : I may be wrong with this, but BASH is a unix shell and as such will
> : try to convert backslashs to forward slashes. It can use either and
> : converts between both.
> : The setup code to populate the environment variables copies DOS memory
> : and as dos uses backslahes when you call getenv() there are
> : backslashes in it. See crt1.c for environment setup.
>
> Hmmm, but TMPDIR is not defined in my normal DOS environment, only in
> bash (.bash_login).
I already asked this in this thread, but got no replies: did you tell
Bash to export your definition of TMPDIR? How _exactly_ did you set
TMPDIR in .bash_login? can you post the relevant fragment?
> Now getenv() & tmpnam() do what I expect: returns "c:/djgpp/tmp/dj10000"
> (but that only 'fixes' TMPDIR, no other variable), and now I'm suspicious
> that there's some weird problem with system()!
There's nothing weird with system, see below.
> > sprintf(buf, "dir %s", n); // c:/djgpp/tmp
> > printf("system(\"%s\")\n", buf);
> > system(buf);
> >
> > return 0;
> > }
>
> with TMPDIR excplicitly set in djgpp.env:
>
> > c:/djgpp/tmp
> > c:/djgpp/tmp/dj500000
> > system("dir c:/djgpp/tmp/dj500000")
> > dir: c\:/djgpp/tmp/dj500000: No such file or directory (ENOENT)
> ^ wtf?
Does your SHELL variable point to Bash? If so, don't use "dir" unless
you install the ported Fileutils; I suspect that Bash is called by
`system' (because `system' notices you want to use it as the shell), and
Bash excapes the special characters such as the colon.
> without TMPDIR explicitly set:
>
> > c:\djgpp\tmp
> > c:\djgpp\tmp/dj500000
> > system("dir c:\djgpp\tmp/dj500000")
> > dir: c\:djgpptmp/dj500000: No such file or directory (ENOENT)
> ^^^ ^
>
> Is dir escaping the backslashes?
No, the shell is unescaping them: Bash removes any single backslashes,
since they are used to quote special characters.
- Raw text -