Issue 27319 - environment parsing foo
Summary: environment parsing foo
Status: CLOSED FIXED
Alias: None
Product: Build Tools
Classification: Code
Component: dmake (show other issues)
Version: OOo 1.1.1RC
Hardware: All All
: P3 Trivial (vote)
Target Milestone: OOo 2.0
Assignee: hjs
QA Contact: issues@tools
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-01 16:21 UTC by mmeeks
Modified: 2004-04-26 18:15 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description mmeeks 2004-04-01 16:21:40 UTC
cygwin likes to export bogus environment variables eg. '!EXITCODE' which screw
up dmake beyond belief - since it parses the whole environment line by line.

This patch fixes this;

diff -u -p -u -r1.3 getinp.c
--- dmake/getinp.c      11 Oct 2002 13:42:43 -0000      1.3
+++ dmake/getinp.c      1 Apr 2004 16:19:25 -0000
@@ -85,8 +85,9 @@ FILE *fil;
       while( (p = Rule_tab[ rule_ind++ ]) != NIL(char) )
         /* The last test in this if *p != '~', handles the environment
          * passing conventions used by MKS to pass arguments.  We want to
-         * skip those environment entries. */
-        if( !Readenv || (Readenv && (strchr(p,'=') != NIL(char)) && *p!='~')){
+         * skip those environment entries. Also CYGWIN likes to export '!'
+         * prefixed environment variables that cause severe pain, axe them too */
+        if( !Readenv || (Readenv && (strchr(p,'=') != NIL(char)) && *p!='~' &&
*p!='!')){
            strcpy( buf, p );
 
            DB_PRINT( "io", ("Returning [%s]", buf) );

A typical warning would be:

Error in startup.mk line 26
Comment 1 mmeeks 2004-04-01 16:24:49 UTC
committed to cws_src680_ooo20040329
Comment 2 mmeeks 2004-04-01 16:29:05 UTC
apparently that cws is shut; hmm.
Comment 3 quetschke 2004-04-01 18:50:28 UTC
Hi Michael!

Please try this workaround and report back.

Enter in Start->Run:

 C:\cygwin\bin\rxvt.exe -sl 1000 -e /usr/bin/bash --login -i

This should do. (The -sl 1000 gives you a thousand lines scrollbuffer, it's
not needed, but convenient.)

Another solution is installing sshd and logging into your Windows machine
and working in a ssh shell. (This is what I always do, therefore I didn't
get the problem.)

The actual problem comes from cygwin being a bit to clever, in its source code,
file environ.cc it says:
  /* Current directory information is recorded as variables of the
     form "=X:=X:\foo\bar; these must be changed into something legal
     (we could just ignore them but maybe an application will
     eventually want to use them).  */ 

Unfortunately !SOMETHING is also not legal :-( I deduct from this and the
existence of !EXITCODE that Windows sometimes has a variable named =EXITCODE.

When using one of the two methods mentioned above to start bash/tcsh there
should be no !X:=X:\foo\bar set.
Comment 4 quetschke 2004-04-01 21:55:55 UTC
I have another one:

Start your tcsh in your cygwin shell with:

$ env `set | sed -ne '/\!/{s/=.*$//; s/^/-u / p}'` tcsh

Sorry, couldn't resist ;-)
Comment 5 quetschke 2004-04-19 17:45:52 UTC
Ahh, well I forgot, patch approved!

Comment 6 sander_traveling 2004-04-21 12:03:14 UTC
closing
Comment 7 hjs 2004-04-26 18:15:40 UTC
.