delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/02/21/15:24:59

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=LgsmtqVG1aUI2C6u
nSSRslv89yJRDSQjOSi4YvwRB0nN09RjK//STPbXHMXd0bhwNBmMz9tRKMTtwzLi
/Mafj9K4gvarKyQN4ZqBiA0dM0b9Orgba9T/ntc5Sbpx3rHLF8fmvyIXpmjGEMSR
CB2Bnc1fgVEhSuKkR3a7OuMSViA=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=8pibfI6lA7YFMRmY/BJ+I7
oD+8I=; b=QEPKJsUdUYmpSkfylqix35n/hhGSg6s001EIaIpK1qTmNIKx/jkPJA
gz+dX0i5+dikgwUo5LvJ5VLid1W6fQBu7vlB2GUA88Y9UZDy49QfYrLB63gHIhG0
XTNH1xNtX8dis7CrxO8HiK1hGW28RKCThnoBm3ia0k9kviK+jhQf0=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=dash, UD:php, documents
X-HELO: mx1.redhat.com
Subject: Re: bash string-operator problem
To: cygwin AT cygwin DOT com
References: <d846545ebaa5469d90f01f84e4f48c3d AT vsrv060ex01 DOT ssd DOT fsi DOT com> <CAD8GWsvqXdG-2YvmVAqW=jkZ_ejHGOj=LCemjoqkF08Vy7i=Fw AT mail DOT gmail DOT com> <608a0fe0-a1eb-6c13-8a6e-0074dcbc166c AT mail DOT com> <CAD8GWsvUBHrbTNxE1RA1gtUhXCD3tD6BgUuPBX_DWJDwHOafDg AT mail DOT gmail DOT com>
From: Eric Blake <eblake AT redhat DOT com>
Message-ID: <7fbf3ef0-35fc-7c00-8f8f-ce90cb281edd@redhat.com>
Date: Thu, 21 Feb 2019 14:24:45 -0600
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0
MIME-Version: 1.0
In-Reply-To: <CAD8GWsvUBHrbTNxE1RA1gtUhXCD3tD6BgUuPBX_DWJDwHOafDg@mail.gmail.com>
X-IsSubscribed: yes

On 2/21/19 2:17 PM, Lee wrote:

>>
>> One equal sign ('=') should be used instead of two equal signs ('==').
> 
> The man page for test says you're correct, but just out of curiosity
> -- why do two equal signs work?

Use of [ ... == ... ] is a bash extension. It works in bash, but is not
portable to other /bin/sh (notoriously == fails in dash, and is not
required by POSIX).

Oddly enough, POSIX is considering standardizing a common subset of [[;
in that case, [[ ... = ... ]] is non-portable, and the proposal only
documents [[ ... == ... ]] as being valid.  For more than you ever
wanted to know, read http://austingroupbugs.net/view.php?id=375

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

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