Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

`test` is the oldest and most portable syntax, "[" is a POSIX synonym which is either a shell built-in (e.g. in bash) or a command i.e. /usr/bin/[ .

You are correct that the author seems to misunderstand what "[" and "test" do, probably by failed analogy with C syntax. In the case of "test foo" for any string "foo", "test" will be evaluating a non-empty expression which is always true.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: