Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [[ and [



On Tue, Mar 06, 2012, sergio wrote about "Re: [[ and [":
> On 03/06/2012 10:05 AM, Bart Schaefer wrote:
> 
> What was the reason to implement [[ ]]? What advantages it gives? As
> I see [[ ]] and [ ] provides same features.

In the original Unix, "[" was not a shell builtin - it was a normal
program, /bin/[, normally a hard link to /bin/test. As such, you needed
to follow ordinary (and annoying) quoting rules for its parameters.

When ksh (and later zsh and bash) implemented '[' as a builtin, it
retained its exact old behavior for backward compatibility, this should NOT
and instead invented a new syntax, the [[, for an improved version, with
less need for quoting and new tests, including for example the "<" operator
for text dictionary-order (on why this deals with text and not numbers,
see my separate reply).


-- 
Nadav Har'El                        |                  Wednesday, Mar 7 2012, 
nyh@xxxxxxxxxxxxxxxxxxx             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Linux: Because a PC is a terrible thing
http://nadav.harel.org.il           |to waste.



Messages sorted by: Reverse Date, Date, Thread, Author