4 ms·
I always use test: - it looks like every other thing in sh (`[` is the outlier) - it prevents confusion like putting `&&` inside the `[ ... ]` brackets (under
by dundarious 4y ago
I always use test:
- it looks like every other thing in sh (`[` is the outlier)
- it prevents confusion like putting `&&` inside the `[ ... ]` brackets (understandable that `[` works that way if you think about it, but it’s another way it’s an outlier)
- mildly discourages use of one particular bash-ism, `[[`, as it works slightly differently, and I prefer POSIX sh unless there is a good justification
- it doesn’t require a closing `]`
I don’t use it for what I think you mean by portability, that is, because `test` exists whereas `[` does not, or anything like that.