From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: "[[" (Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash))
Date: Sat, 16 Oct 1999 15:33:46 +0000 [thread overview]
Message-ID: <991016153346.ZM27414@candle.brasslantern.com> (raw)
In-Reply-To: <rsqvh879zof.fsf@crane.jaist.ac.jp>
On Oct 16, 10:56pm, Tanaka Akira wrote:
} Subject: Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash
}
} In article <38074889.6DCA13F@u.genie.co.uk>,
} Oliver Kiddle <opk@u.genie.co.uk> writes:
} >
} > > * Use [[ ... ]] instead of [ ... ].
} >
} > Could someone please explain why [[ ... ]] seems to be prefered where
} > both forms provide the same functionality ? Sven also changed my use of
} > [ -d ... ] to use the double square brackets. Is it faster or something?
}
} I'm not sure about this. But I believe the description of `test' in
} zshbuiltins(1).
PWS says in http://www.ifh.de/~pws/computing/zshguide02.html#l6
Second aside for users of sh: you may remember that tests in sh used
a single pair of brackets, `if [ ... ]; then ...', or equivalently
as a command called test, `if test ...; then ...'. The Korn shell
was deliberately made to be different, and zsh follows that. The
reason is that `[[' is treated specially, which allows the shell to
do some extra checks and allows more natural syntax. For example,
you may know that in sh it's dangerous to test a parameter which
may be empty: `[ $var = foo ]' will fail if $var is empty, because
the word is missed out and the shell never knows it was supposed
to be there (I'll explain about parameters shortly); with `[[ ...
]]', this is quite safe because the shell is aware there's a word
before the `=', even if it's empty. Also, you can use `&&' and
`||' to mean logical `and' and `or', which agrees with the usual
UNIX/C convention; in sh, they would have been taken as starting a
new command, not as part of the test, and you have to use the less
clear `-a' and `-o'. Actually, zsh provides the old form of test for
backward compatibility, but things will work a lot more smoothly if
you don't use it.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
next prev parent reply other threads:[~1999-10-16 15:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-15 12:10 PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Sven Wischnowsky
1999-10-15 15:30 ` Oliver Kiddle
[not found] ` <991015155008.ZM24081@candle.brasslantern.com>
1999-10-15 16:05 ` Oliver Kiddle
1999-10-15 16:40 ` Bart Schaefer
1999-10-15 16:54 ` _urls ... and CVS Adam Spiers
1999-10-16 5:18 ` Tanaka Akira
1999-10-16 13:56 ` PATCH: _urls again (Re: setopt localoptions noautoremoveslash) Tanaka Akira
1999-10-16 15:33 ` Bart Schaefer [this message]
1999-10-18 6:59 "[[" (Re: PATCH: _urls again (Re: setopt localoptions noautoremoveslash)) Sven Wischnowsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=991016153346.ZM27414@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).