What's the meaning of a trailing colon to dash's builtin test
(or [
) command? I was surprised when I found that if [ ... ]: ; then .. ; fi
works (at all) in dash
, but not bash
, and it seems to be because the builtin's behavior differs from the command's.
$ /usr/bin/\[ 1 ] && echo 1
1
$ /usr/bin/\[ 1 ]: && echo 1
/usr/bin/[: missing `]'
$ [ 1 ]: && echo 1
1
[ 1 ]foo && echo 1
do? My wild initial guess is that dash is checking whether the argument starts with]
instead of whether it's equal to]
. – godlygeek Mar 26 at 19:07[ 1 ]foo && echo 1
prints1
, so @Arcege's right. – David Ehrmann Mar 26 at 19:19