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=LgsmtqVG1aUI2C6u nSSRslv89yJRDSQjOSi4YvwRB0nN09RjK//STPbXHMXd0bhwNBmMz9tRKMTtwzLi /Mafj9K4gvarKyQN4ZqBiA0dM0b9Orgba9T/ntc5Sbpx3rHLF8fmvyIXpmjGEMSR CB2Bnc1fgVEhSuKkR3a7OuMSViA= 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=8pibfI6lA7YFMRmY/BJ+I7 oD+8I=; b=QEPKJsUdUYmpSkfylqix35n/hhGSg6s001EIaIpK1qTmNIKx/jkPJA gz+dX0i5+dikgwUo5LvJ5VLid1W6fQBu7vlB2GUA88Y9UZDy49QfYrLB63gHIhG0 XTNH1xNtX8dis7CrxO8HiK1hGW28RKCThnoBm3ia0k9kviK+jhQf0= 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=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=dash, UD:php, documents X-HELO: mx1.redhat.com Subject: Re: bash string-operator problem To: cygwin AT cygwin DOT com References: <608a0fe0-a1eb-6c13-8a6e-0074dcbc166c AT mail DOT com> From: Eric Blake Message-ID: <7fbf3ef0-35fc-7c00-8f8f-ce90cb281edd@redhat.com> Date: Thu, 21 Feb 2019 14:24:45 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes On 2/21/19 2:17 PM, Lee wrote: >> >> 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? Use of [ ... == ... ] is a bash extension. It works in bash, but is not portable to other /bin/sh (notoriously == fails in dash, and is not required by POSIX). Oddly enough, POSIX is considering standardizing a common subset of [[; in that case, [[ ... = ... ]] is non-portable, and the proposal only documents [[ ... == ... ]] as being valid. For more than you ever wanted to know, read http://austingroupbugs.net/view.php?id=375 -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org -- 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