From: John Kelly on
On Tue, 10 Aug 2010 01:33:16 -0700, William Ahern
<william(a)wilbur.25thandClement.com> wrote:

>> I thought [[ ... ]] was portable.

>Not really. Portability is a fuzzy term, but what POSIX specifies is so
>minimal it's as good a baseline as any. POSIX reserves "[[" but leaves its
>use unspecified. See POSIX.1-2008, Shell & Utilities volume, section
>2.4.

> http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_04

>The spec is so relatively short it's not much of a hassle to read it through
>once. That way you can likely exclude as portable anything not well defined
>according to POSIX. Of course, it still might not be de facto portable even
>if well defined.

OK.

I wonder what shells don't provide [[ ... ]]

Hopefully I will never use them ...



--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php

From: Ben Bacarisse on
John Kelly <jak(a)isp2dial.com> writes:

> I've been using something like this:
>
> [[ a/bc == [^/]*/*[^/] ]] && echo match
>
> (the "a/bc" is an example value)
>
> to test whether a variable contains a file name having a relative path,
> and it worked fine with bash.

This obviously suits your usage, but a string with no slashes is a file
name having a relative path but it fails your test.

<snip>
--
Ben.
From: John Kelly on
On Tue, 10 Aug 2010 15:55:44 +0100, Ben Bacarisse <ben.usenet(a)bsb.me.uk>
wrote:

>John Kelly <jak(a)isp2dial.com> writes:
>
>> I've been using something like this:
>>
>> [[ a/bc == [^/]*/*[^/] ]] && echo match
>>
>> (the "a/bc" is an example value)
>>
>> to test whether a variable contains a file name having a relative path,
>> and it worked fine with bash.
>
>This obviously suits your usage, but a string with no slashes is a file
>name having a relative path but it fails your test.

Right.

I poorly worded its intended usage. This is the actual code:

[[ $this == [^/]*/*[^/] ]] && mkdir -p .diff/${this%/*}
diff -Nru a b > .diff/$this || test 2 -gt $? ||
quit "failure diffing $REPLY"

a and b are symlinks pointing to two directory tress, so that diff
always produces a consistent header, for use with patch -p1.

The result of diff goes into the .diff directory tree. If there's only
one path component in $this, the diff goes into the base .diff directory
and I don't need to create any subdirectories. But if there's more than
one path component in $this, I need to create a subdirectory structure
within .diff for all but the last one.

So it's not really a "file name" I'm talking about.

Sorry for poor documentation, but that's sometimes what you get from
programmers, especially when they try to write "standards." Just look
at how much trouble three lines of code can be. ;-)


--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php

From: Sven Mascheck on
John Kelly wrote:

> I wonder what shells don't provide [[ ... ]]

traditional Bourne shells
Almquist shells
posh

while these shells for example (at least later releases) know it:

bash (since -2)
ksh88 (since 88a, == is not recognized until 88g)
ksh93
mksh
pdksh
zsh


> Hopefully I will never use them ...

"ymmv"
--
http://www.in-ulm.de/~mascheck/various/shells/
From: John Kelly on
On Tue, 10 Aug 2010 18:40:24 +0000 (UTC), Sven Mascheck
<mascheck(a)email.invalid> wrote:

>John Kelly wrote:

>> I wonder what shells don't provide [[ ... ]]

>while these shells for example (at least later releases) know it:

>bash (since -2)
>ksh88 (since 88a, == is not recognized until 88g)
>ksh93
>mksh
>pdksh
>zsh

>--
>http://www.in-ulm.de/~mascheck/various/shells/

Nice web page, thanks.



--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php