delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/02/21/12:40:11

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=iyJ2fYEGtdc0wc09
IjW/fm/RFDkcmRES9fIO9eKvEz/JtOu1OQUHya5oVAf8E3ZgW9QQ1AFAys79O+4E
mA7uub9pLpgK8Nxzjtc76pZKRc0xIoCNxGJNEKoce5i9snQ3KnDaKgsDoTM231jC
aniEQ7GEoMNq4lA2arZgy5w0hSM=
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=q+4dSQ+8I1Ca7fPKgc2L8i
yrCes=; b=EWRGlxKuNdPABhfpTBy4wVUjdTaReBGLhHEyrm/1lZ/7D8ROLxdOjl
aXkRREySl/acX3BfIxHLeRLfMSsR1FCj/M1jnFZgCwcn5bEDRZfw2ZU0Gi1vizgu
RMqVX3iWL3FAeb7BuBLpj7fnhwOmA6nHkY6ncu4RUBqb968OFj93c=
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=-7.3 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Lee, doe, signs, H*F:D*mail.com
X-HELO: mout.gmx.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.com; s=dbd5af2cbaf7; t=1550770796; bh=TJy+1TpfChg9oOczRYPMRePqIMmGict5ww0lXYfSDRk=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=ZaU8Ww1StyUMt+dIPnciNXIlvao39bs+ZtZfKq1GvZUv5SPGjrraXq7RLxG2q9TyV IAkjjBt2W2HatVBQrxU48Z03/XDoixtqKnuLrTCjr6X3JKyaf3Qza1fc1VPX3QS9Y8 AyfPodn6xWzqYZFDxyjAdDGQ31jIsJBTWZjlM0Lk=
X-UI-Sender-Class: 214d933f-fd2f-45c7-a636-f5d79ae31a79
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>
From: john doe <johndoe65534 AT mail DOT com>
Message-ID: <608a0fe0-a1eb-6c13-8a6e-0074dcbc166c@mail.com>
Date: Thu, 21 Feb 2019 18:39:56 +0100
MIME-Version: 1.0
In-Reply-To: <CAD8GWsvqXdG-2YvmVAqW=jkZ_ejHGOj=LCemjoqkF08Vy7i=Fw@mail.gmail.com>
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id x1LHeA1o015180

On 2/21/2019 5:18 PM, Lee wrote:
> On 2/21/19, Rockefeller, Harry  wrote:
>> CYGWIN_NT-6.1 HARRYR-PC 3.0.0(0.336/5/3) 2019-02-16 13:21 x86_64 Cygwin
>> GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin)
>>
>> #!/bin/bash
>> A="A"
>> B="A"
>> if [ $A!=$B ]; then          <----- needs spaces around the !=
>>     echo -e "not identical"
>> fi
>> if [ $A==$B ]; then         <------ needs spaces around the ==
>>     echo -e "identical"
>> fi
>> exit 0
>>
>> Running this script gives
>> not identical
>> identical
>>
>> Both tests are true.
>
> because you're testing "A==B"
> you need to give 3 parameters  "A"  "=="  "B"
>
> $ cat x
> #!/bin/bash
> A="A"
> B="A"
> if [ $A != $B ]; then
>     echo  "not identical"
> fi
> if [ $A == $B ]; then
>     echo  "identical"
> fi
> if [ A!=B ]; then
>     echo  "not identical"
> fi
> if [ A==B ]; then
>     echo  "identical"
> fi
>

One equal sign ('=') should be used instead of two equal signs ('==').

--
John Doe

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