From 45ba8a5f3b4f15a5bd410f04a5687efe255b36a5 Mon Sep 17 00:00:00 2001 From: koalaman Date: Mon, 25 Jan 2016 19:43:11 -0800 Subject: [PATCH] Created SC2175 (markdown) --- SC2175.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 SC2175.md diff --git a/SC2175.md b/SC2175.md new file mode 100644 index 0000000..b80535b --- /dev/null +++ b/SC2175.md @@ -0,0 +1,22 @@ +## Quote this invalid brace expansion since it should be passed literally to eval + +### Problematic code: + +```sh +eval echo {1..$n} +``` + +### Correct code: + +```sh +eval "echo {1..$n}" +``` +### Rationale: + +Using `eval somecommand {1..$n}` depends both on bash silently failing to interpret the brace expansion, and on it passing failing brace expansions literally. + +Rather than depending on these questionable features (which already behave differently in other shells), use the explicit, predictable way of passing values literally: quoting. + +### Exceptions: + +None. \ No newline at end of file