mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2075 (markdown)
27
SC2075.md
Normal file
27
SC2075.md
Normal file
@@ -0,0 +1,27 @@
|
||||
## Escaping `\<` is required in `[..]`, but invalid in `[[..]]`
|
||||
|
||||
### Problematic code:
|
||||
|
||||
```sh
|
||||
[[ aardvark \< zebra ]]
|
||||
```
|
||||
|
||||
### Correct code:
|
||||
|
||||
```sh
|
||||
[[ aardvark < zebra ]]
|
||||
```
|
||||
|
||||
### Rationale:
|
||||
|
||||
Grammatically speaking, `[` is considered a normal command name, so `<` and `>` are interpreted as redirections. When using the lexicographical string operators `<` and `>` in `[ .. ]`, they must be escaped (e.g. `\<` or `"<"`).
|
||||
|
||||
`[[` is considered its own grammatical construct, and therefore it does not require (nor does it allow) escaping `<` or `>`.
|
||||
|
||||
### Exceptions:
|
||||
|
||||
None
|
||||
|
||||
### Related resources:
|
||||
|
||||
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
Reference in New Issue
Block a user