On Tuesday 19 December 2006 17:10, Volker Kuhlmann wrote:
> > > use != instead of -ne
> > >
> > > man test for the gore.
> >
> > Be aware that `test` is an external program whereas the standard `if [ ]`
> > construct is built into your shell. There may be inconsistencies with the
> > type of tests that they support.
>
> I have some doubts about this distinction. If you look into the details,
> you'll find that "if" is part of the shell's control flow, and that "["
> and "test" are in fact the same program (there's a symlink). If it's
> used as "[", it'll moan if its last argument is not "]", although this
> last argument does absolutely nothing but keep the sh syntax look
> better. Once upon a time, sh would have had neither "[" nor "test" and
> both would have been an external program. With bigger hardware it was ok
> to integrate a copy of them into sh itself for efficiency (calling
> external programs creates overheads), and there's no point integrating
> one without the other, as they are in fact the same anyway. Looking at
> the bloated size of the /bin/bash binary, there better be a lot more
> than just "test" integrated as well.

The reason I mentioned it was that I was discussing scripting with sh in a 
cross platform build system with some people the other day.

The sh (real sh not a symlink to bash/dash) in some *nix operating systems 
(Solaris and some of the BSDs were the ones that come to mind) does not 
support -nt and some other options where as the test binary did.

It's just something to be aware of.

hads

-- 
http://nicegear.co.nz
New Zealand's VoIP supplier

Reply via email to