This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: programming API to determine whether in "Cygwin environment"
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 11 Jul 2008 01:06:15 -0400
- Subject: Re: programming API to determine whether in "Cygwin environment"
- References: <18395872.post@talk.nabble.com>
- Reply-to: cygwin at cygwin dot com
On Thu, Jul 10, 2008 at 08:49:06PM -0700, Tony Last wrote:
>
>My console program is built for native Windows (thus does not reply on
>cygwin1.dll). However, people may want to use it in a Cygwin environment and
>if they do I want it to behave in a suitably "Unixy" way. The obvious
>example is that when it prints out a pathname (which happens a lot) a Cygwin
>user would prefer to see it in Cygwin style, including forward slashes.
>
>So I'm looking for a boolean method which will allow a program to tell
>whether it was run from within a Cygwin shell. An environment variable would
>be fine as long as it's standard. In fact I see a number of env vars which
>would enable an educated guess but am wondering if there's a defined
>standard and safe way.
A PATH containing colons which weren't preceded by just a single
alphabetic character would be a clue but it wouldn't be foolproof. A
HOME environment variable with no colons and forward slashes would be
another clue. I don't think there is a foolproof test, though.
cgf
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/