1

I used to think [ would spawn /usr/bin/test and [[ was a builtin, but apparently, it doesn't:

$ strace bash -c " [ -z "$FOO" ] && echo yes " 2>&1 | grep test

and

$ type [
[ is a shell builtin

[ is a shorter and seems more portable too. I'm on GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu).

  • Ok, so TL;DR: no, unless I'm using one of the special features of [[. Great link +1, @jasonwryan! – PSkocik Jun 8 '15 at 7:01
  • I think you misread the page: if your shebang is bash, you should always prefer [[ over [. – jasonwryan Jun 8 '15 at 7:04

Browse other questions tagged or ask your own question.