delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/12/12/14:51:27

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Sun, 12 Dec 2010 14:51:08 -0500
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Executable named "[.exe" in c:\cygwin\bin?
Message-ID: <20101212195108.GF14369@ednor.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <AANLkTiktvSMLdZ_1+oDGg9kOVHbhRAX7K_s+c72mUDQe AT mail DOT gmail DOT com> <AANLkTimtxEVwMF-bDWot2OO7pGZ7uz1K5hQEw+H9efPX AT mail DOT gmail DOT com> <4D04C14E DOT 90607 AT gmx DOT de>
MIME-Version: 1.0
In-Reply-To: <4D04C14E.90607@gmx.de>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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 Sun, Dec 12, 2010 at 01:34:22PM +0100, Matthias Andree wrote:
>Am 12.12.2010 13:31, schrieb Csaba Raduly:
>
>> I guess something like this:
>> 
>> [ -f file ] && echo is
>
>True, but this is bad style.  Reason is you cannot run scripts containing this
>under a "set -e" regime.  However, most scripts should be doing that (and set -u
>is also often advised), so that errors don't go unnoticed.

The above should work as expected with set -e.  In fact, you need to do
something like that if you've used "set -e".

Consider the variant:

#!/bin/sh -e
[ -f /fmp/fonexistent ] || echo nonexistent

It works just fine.

cgf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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