delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/09/29/09:52:58

X-Spam-Check-By: sourceware.org
Date: Fri, 29 Sep 2006 09:50:40 -0400
From: "Kenneth Nellis" <knellis AT syntek-usa DOT com>
Subject: cygwin detection
To: <cygwin AT cygwin DOT com>
Message-id: <001601c6e3ce$403f0d80$be32000a@idirect.net>
MIME-version: 1.0
X-Mailer: Microsoft Office Outlook 11
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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

Couldn't find anything relevant in the archives or the documentation...

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.

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

if [ -f /usr/bin/cygwin1.dll ]; then
if [ $CYGWIN_ROOT ]; then
if [ $OSTYPE = cygwin ]; then
if [ $(uname -s | grep -c CYGWIN) -gt 0 ]; then
if [ $(grep -c cygwin <<< ${BASH_VERSINFO[5]}) -gt 0 ]; then
if is_cygwin; then    # where is_cygwin is a locally-built C program
                      # that tests #ifdef __CYGWIN__

--Ken Nellis


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