3 ms·
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? I
by chatmasta 3y ago
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?
- kqr 3y agoIt 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.