help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Definitive answer of the difference between [ and [[


From: Eric Blake
Subject: Re: [Help-bash] Definitive answer of the difference between [ and [[
Date: Mon, 03 Feb 2014 07:54:38 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 02/01/2014 02:38 PM, Bob Proulx wrote:

> However '[[' is a new shell feature of ksh, bash, zsh, probably
> others.  It isn't a _standard_ shell feature.

At least, not yet.

>  It won't work with
> "#!/bin/sh" scripts.  When using '[[' you need to use "#!/bin/bash" or
> /bin/sh as it is a feature specific to ksh and ksh-like shells.

The POSIX folks have a proposal to add '[[' to the shell for the next
version of POSIX (still several years out):
http://austingroupbugs.net/view.php?id=375

If you want a definitive difference between '[' and '[[', it pays to
read what is being proposed for standardization, and places where bash
and ksh picked different behaviors for '[[' which in turn makes
standardization more difficult (for example, does [[ 0x10 > 11 ]] treat
0x10 as a hex number or as a syntax error - or worse, the current ksh
behavior which strips leading 0 then treats it as the arithmetic value
of the variable $x10).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]