From e35ac5771946dfbadd792a1eb9e8cbb325b2f22f Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Wed, 19 Oct 2022 21:36:39 -0700 Subject: [PATCH] Created SC2075 (markdown) --- SC2075.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 SC2075.md diff --git a/SC2075.md b/SC2075.md new file mode 100644 index 0000000..a3a6b45 --- /dev/null +++ b/SC2075.md @@ -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! \ No newline at end of file