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

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:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; q=dns; s=default; b=MK3VDlC
MRTLPJkbI0hB8YG34CD3e7TE6jvBwEoyoe3K+yCT74snOdmpr8mo1b34qTYt43FF
wDALZJRTY+0jVMgfNizCPH9GY+jJwZGzbKUhvlwReqGEr6YqTKWmCTeTjTCMcL7h
35WaaZjNrZBTTsb9Jc/J9pEXvaoz7Y77eRs4=
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:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; s=default; bh=gJLtpmbujXc1h
6u0/47LGgu0dg8=; b=org5IPM4u1aQr9fFPIgB6LpCz/OJhE9i/Ut5mSoFhjCqy
Jw+07XfxbA3CxCaJ8FgERul88S/hZLiPvXV3xpKYvum4YhaEor3GBUU2pWKcvtDr
87KsytCfeVA7UecdyaWM8dVCptY9SSHPRMAtrwWiwJAtTa2/ktIB5DDipNnLDI=
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=-6.7 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=a, A
X-HELO: mail-io1-f49.google.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=XjjEGBG9oQixem9IKJqQGlSB2h3Goe53VcAyR4Zno3M=; b=YNk0slc4yf9UkNNx6rCg1q2F3BIZ3DOEtXu55QXjc8bDQc/q/eI97UXBrGophupvLD XVkWLbsttXSI33fL5f2mKxWV5Il5LLSNe49fzPhQxImxATMq3K6pCiks+I3GVEpguveJ YPRORcALdznZyFt6gdVg8tvEIvNZoGfc74Jg9gDrg9PzcrMm/veMpfcBzrcMMFK6OiPd GXtkMqIDfcvyyOkXPciXHwiDFCHfuStdGlOP2knf55aMR29Ou/TKlf1R8/1IWz/DhoQh rf44G9Xq/ljDtxmEg8ISp6umDdyxY16FhIG5jE+xxxT/lhU7Z3NxUQGMz9qekdhn1MgF a+yw==
MIME-Version: 1.0
In-Reply-To: <608a0fe0-a1eb-6c13-8a6e-0074dcbc166c@mail.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>
From: Lee <ler762 AT gmail DOT com>
Date: Thu, 21 Feb 2019 15:17:31 -0500
Message-ID: <CAD8GWsvUBHrbTNxE1RA1gtUhXCD3tD6BgUuPBX_DWJDwHOafDg@mail.gmail.com>
Subject: Re: bash string-operator problem
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

On 2/21/19, john doe wrote:
> 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
  <.. snip ..>
>
> 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?

$ cat /tmp/x
#!/bin/bash
A="A"
B="A"
if [ $A == $B ]; then
    echo  "identical"
fi
if [ $A = $B ]; then
    echo  "identical"
fi

$ bash /tmp/x
identical
identical

Thanks,
Lee

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