Re: bash string-operator problem
- Date: Thu, 21 Feb 2019 14:24:45 -0600
- From: Eric Blake <eblake@xxxxxxxxxx>
- Subject: Re: bash string-operator problem
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
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple