From c8233ab444a6a6fed221ab67d240cf95cadc4220 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Wed, 19 Oct 2022 21:08:36 -0700 Subject: [PATCH] Created SC1138 (markdown) --- SC1138.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 SC1138.md diff --git a/SC1138.md b/SC1138.md new file mode 100644 index 0000000..d8e616c --- /dev/null +++ b/SC1138.md @@ -0,0 +1,35 @@ +## Shells are space sensitive. Use '< <(cmd)', not '<< (cmd)'. + +### Problematic code: + +```sh +while read -r line +do + echo "You said: $line" +done <<(cmd) +``` + +### Correct code: + +```sh +while read -r line +do + echo "You said: $line" +done < <(cmd) +``` +### Rationale: + +When redirecting `<` from a process substitution `<(cmd)`, make sure there is a space between the two `<` characters as shown in the example. + +With a space `cmd1 < <(cmd2)`, is correctly interpreted as "run cmd1, reading stdin from cmd2, without forking for a pipeline". + +Without a space, `<<` is incorrectly considered a here document, and `(cmd2)` is an invalid delimiter token. + + +### Exceptions: + +None + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file