Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [[ and [
- X-seq: zsh-users 16824
- From: Kurtis Rader <krader@xxxxxxxxxxxxx>
- To: sergio <mailbox@xxxxxxxxxxxxx>
- Subject: Re: [[ and [
- Date: Sat, 3 Mar 2012 20:50:05 -0800
- Authentication-results: mr.google.com; spf=pass (google.com: domain of krader@xxxxxxxxxxxxx designates 10.60.1.3 as permitted sender) smtp.mail=krader@xxxxxxxxxxxxx
- Cc: zsh-users@xxxxxxx
- In-reply-to: <4F52D510.6000002@sergio.spb.ru>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <4F52D510.6000002@sergio.spb.ru>
To expand on Bart's reply the "if [ ]" form goes back to the original
Bourne shell (probably before you were born but not before I was born :-)
which only supported invoking external programs and evaluating their exit
status. The left square-bracket was actually a filesystem alias for
/bin/test (or /usr/bin/test). Although today it is more likely that both
the "[" and "test" commands are built-ins to the shell that exhibit the
historic semantics. Whereas "[[" is a token that triggers the shell to
parse the contents up to the matching "]]" using different rules. I believe
the "[[ ]]" notation was introduced by the Korn shell after David Korn who
wrote the first version.
On Sat, Mar 3, 2012 at 6:36 PM, sergio <mailbox@xxxxxxxxxxxxx> wrote:
> Hello.
>
> It's dumb question, but I can't find this in man.
>
> What it the difference between [[ ]] and [ ]?
> if [[ ]]; then ... fi
> and
> if [ ]; than ... fi
>
> OK, the first is an evaluating of the conditional expression, and what
> is the second?
>
> --
> sergio.
>
--
Kurtis Rader
Caretake of the exceptional canines Einstein and Chino
Messages sorted by:
Reverse Date,
Date,
Thread,
Author