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: List-Subscribe: List-Archive: List-Post: List-Help: , 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: From: john doe 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: Content-Type: text/plain; charset=utf-8 X-IsSubscribed: yes Content-Transfer-Encoding: 8bit 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