Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • Note that in bash, it would return yes for " 123 " for instance. You wouldn't want to use that approach in ksh where it would not only work but also be a command injection vulnerability. Commented Jan 25, 2021 at 10:50
  • The entire matter of testing with "[[" vs "[", and the subtle differences therein which can often be lost to memory after reading up on the matter after only a few months, is precisely demonstrated in this answer. Therefore, I consider any type of pattern that is not reliable in any type of shell to be a "bad". As a result, I tend to make all code within a script use only one or the other type of test (i.e. if using bash, every test should be "[[" and would be considered "bad" if ever using "[" anywhere. Likewise for bourne shell, you can only use "[" and this type of test would be OK there) Commented Aug 10, 2023 at 20:16