delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/09/29/11:49:45

X-Spam-Check-By: sourceware.org
Date: Fri, 29 Sep 2006 08:49:30 -0700
From: George <d1945 AT sbcglobal DOT net>
To: cygwin AT cygwin DOT com
Subject: Re: cygwin detection
Message-ID: <20060929154930.GA1132@home>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <001601c6e3ce$403f0d80$be32000a AT idirect DOT net>
Mime-Version: 1.0
In-Reply-To: <001601c6e3ce$403f0d80$be32000a@idirect.net>
User-Agent: Mutt/1.4.2.1i
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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

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/

- Raw text -


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