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

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=e51bFis
qAB16UrXeZQGzqI7xFAeJMJS7f0TAOSS1H4a6K4J1ilrFB0ELKwDXQ7wyW2KcCKX
MwQxewJyUyQ7c/HFlFkmIEPj8qaNyxkf82sg6rpCHwKeScM7Pn5XSGOJmDWLf/Zl
eAE6xne9q6uPaVBc0f0P9Ke/PKN6175IP6Yc=
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=Q/L0L4gOEPJr5
yFG7QEXDyuLjuY=; b=Q0eAhXgm/1k5swBNPiBOj9vHUBFiU7YcZbo2Ew0M57aP5
mLKKiVTeQjeJ8e9viFVet8X69ZC+qNasqA6KfUDlLL1bvXrES0tbx43AnKm6fQRz
7R1AaLoV0AuQcPGE61i5QXwjf3yTkzK+sQ0oLHYc7AVCOrFem685BzO+08jiY0=
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, lee, a
X-HELO: mail-it1-f174.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=4FbM3aHRnIkkNlc8tMcn8Jt6y6ZNS8TyZ8DRsLyUTyw=; b=eGsOOUhy5Ci+OFcWltRTMnjLJ2OYPygi+3wwPnGVSsWDKZkR1AsOTk/eP2wy1YrcID Zjyt2K4tMm8bhVsGA2GCcuXxPPlqeluJoTOAyVnp4hwDzNBVywCT48fgGeYd758caAxp po8Hjcu5GoIKHXyaqz9rvttP1gUjSrY4NWN0ypWhJtSRBK9mvhabdbuiSS33wX1Y8Haq x0e0HiNu90SauQi6LM9REc52c04cD/H2c0hCsPoeg/m4sNqOl+vQiwQ5D1KfTblThM5m qY+rpwD6zdtMNMngbKZBYum2XmjjvjjGvBCfhwCIYdv88HG9dy5/IQRepO3/KapoZHPV 2nqw==
MIME-Version: 1.0
In-Reply-To: <d846545ebaa5469d90f01f84e4f48c3d@vsrv060ex01.ssd.fsi.com>
References: <d846545ebaa5469d90f01f84e4f48c3d AT vsrv060ex01 DOT ssd DOT fsi DOT com>
From: Lee <ler762 AT gmail DOT com>
Date: Thu, 21 Feb 2019 11:18:13 -0500
Message-ID: <CAD8GWsvqXdG-2YvmVAqW=jkZ_ejHGOj=LCemjoqkF08Vy7i=Fw@mail.gmail.com>
Subject: Re: bash string-operator problem
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

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

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