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: 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=-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: References: From: Lee Date: Thu, 21 Feb 2019 11:18:13 -0500 Message-ID: Subject: Re: bash string-operator problem To: cygwin AT cygwin DOT com Content-Type: text/plain; charset="UTF-8" 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