On Tue, Jul 17, 2007 at 11:42:14AM -0400, Eric Furman wrote:
| > | > And then lists some exceptions. This could be a difference between sh
| > | > and ksh (which, I believe, is only a difference in documentation).
| > |
| > | It does different things depending on whether it's run as ksh or sh.
| >
| > As far as my quick test (not definitive by any means) shows, it does
| > not do anything different with respect to handling [[ ]].
| >
| > The description of [[ ]] is missing from sh(1) though, hence my
| > statement "which, I believe, is only a difference in documentation".
|
| [[ is not listed in sh(1) because this construct doesn't exist in sh(1).
| There is a difference in the [[ construct in ksh. Read man ksh(1).
| Most significantly;
| o Field splitting and file name generation are not per-
| formed on arguments.
| o The second operand of the `!=' and `=' expressions are
| patterns (e.g. the comparison [[ foobar = f*r ]] suc-
| ceeds).
This difference is only in the documentation. The following two
constructs behave the same in /bin/sh and /bin/ksh :
[[ foobar = f*r ]] && echo YES || echo NO
[ foobar = f*r ] && echo YES || echo NO
At least, they do when I just tried :
$ echo $SHELL
/bin/ksh
$ [[ foobar = f*r ]] && echo YES || echo NO
YES
$ [ foobar = f*r ] && echo YES || echo NO
NO
$ chsh -s /bin/sh
<logout, login>
$ echo $SHELL
/bin/sh
$ [[ foobar = f*r ]] && echo YES || echo NO
YES
$ [ foobar = f*r ] && echo YES || echo NO
NO
I see very little differnece. Like I said, only in the documentation.
And I do believe this has been discussed on this list before ;)
Cheers,
Paul 'WEiRD' de Weerd
--
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
http://www.weirdnet.nl/
[demime 1.01d removed an attachment of type application/pgp-signature]