This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygwin detection


On Fri, Sep 29, 2006 at 09:50:40AM -0400, Kenneth Nellis wrote:
> I have bash scripts that I want to run identically under Cygwin and 
> Linux, which sometimes require the scripts to detect the environment 
> and branch accordingly. There are numerous ways to do Cygwin detection, 
> but I was wondering what technique should work with the widest audience 
> and be most immune to future Cygwin developments.

The widest audience, in your case, being one?  ;-)

> FWIW, below are various techniques that work for *me* *today*, some of 
> which have obvious flaws.
>
> [...]

#!/bin/sh

case "`uname`" in
	Linux   ) echo "Don't fear the penguin."     ;;
	CYGWIN* ) echo "Don't fear the hippos!"      ;;
	FreeBSD ) echo "This is Unix. I know this."  ;; 
	*       ) echo "God just killed a kitten."   ;;
esac

FWIW, you may want to consider doing the same to your .bashrc, etc.
files.  I can't imagine, for example, such things as aliases on a
Windows+Cygwin system being useful across platforms.

-- 
George

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]