X-Spam-Check-By: sourceware.org
Date: Fri, 29 Sep 2006 08:49:30 -0700
From: George <d1945@sbcglobal.net>
To: cygwin@cygwin.com
Subject: Re: cygwin detection
Message-ID: <20060929154930.GA1132@home>
Mail-Followup-To: cygwin@cygwin.com
References: <001601c6e3ce$403f0d80$be32000a@idirect.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <001601c6e3ce$403f0d80$be32000a@idirect.net>
User-Agent: Mutt/1.4.2.1i
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

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/

