delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/09/24/05:41:50

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4ABB3ECA.7030504@gmx.de>
Date: Thu, 24 Sep 2009 11:41:30 +0200
From: Matthias Andree <matthias DOT andree AT gmx DOT de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Is this a known problem with getenv() ?
References: <005f01ca3c4b$e5385b10$4001a8c0 AT mycomputer> <20090923121735 DOT GA20981 AT calimero DOT vinschen DOT de> <002f01ca3c57$532cd9b0$4001a8c0 AT mycomputer> <001701ca3c76$ef1a0db0$4001a8c0 AT mycomputer>
In-Reply-To: <001701ca3c76$ef1a0db0$4001a8c0@mycomputer>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

John Emmas schrieb:
> ----- Original Message ----- 
> From: "John Emmas"
>>
>> I might just try experimenting with a very simple program and see if I
>> still get the error
>>
> I partially tracked down the problem, although I don't quite know how to
> solve it.  If I write this simple console app:-
> 
> #include <stdio.h>
> #include <stdlib.h>
> 
> int main ()
> {
>    printf ( getenv ("PATH") );
>    return 0;
> }

Gee, that is INSECURE. Insert some % in PATH for major fun including crashes
(anyone mistyping CMD.COM like variable expansions for instance, for instance
%USERPROFILE%)

For the records, the right way to do it is either:

	puts(getenv("PATH"));

or

	printf("%s\n", getenv("PATH"));


I've seen commercial Windows Explorer extensions (SECURITY software incidentally
that shipped with my laptop) kill my Explorer from such beginner's mistakes, and
it's a pity such bogus code is in publicly visible archives and needs to be
corrected through messages like mine.

> it outputs the correct path.  However, if I create a GUI app and launch it
> under 'X', the path seems to change and includes lots of duplicated folders.

Probably one of the start scripts adds lots of entries, and X...

> I figured out that startxwin.bat is adding a few duplicated entries to my
> path but that doesn't explain why there are so many duplications and I don't
> know where the others might be coming from.  However, I don't get any
> duplicates at all if I run XWin directly, instead of starting it with
> startxwin.bat.

...isn't the sole candidates. Check the manuals of involved shells for which
files they read at startup, under which conditions, and how. .bashrc, .profile
and corresponding files under /etc are prime candidates.

This isn't Cygwin or Cygwin/X specific though, but general Unix behaviour.

Cheers

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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