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

What bothers me is that you can write equivalent code with `test` and `[`, but when using `[` you need to terminate your conditional expression with `]`. Why? Isn't it the same binary? Why is the shell adding this extraneous requirement, just to surface "syntax errors" rather than simply treating `]` as a no-op?


It is the test command that requires the terminating ] when it is invoked as [.

It's possible your shell pre-empts this requirement and presents it as a proper syntax error, but it would have failed anyway.




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

Search: