GNU bash, version 4.3.46(1)-release (x86_64-unknown-linux-gnu) GCC: (GNU) 6.1.1 On archlinux 4.4.27-1-lts
Hello, today i tried something simple but it leads to what seems to be a bug. $ var="$(for ((i=0;i<$#;i++));do echo line;done)" leads to: "unexpected EOF while looking for matching `)' I think it's because bash interprets "^#" as "#" which means that what follow is commented. It works, when $# is replaced by any number: $ var="$(for ((i=0;i<5;i++));do echo line;done)" It works with backticks: $ var=`for ((i=0;i<$#;i++));do echo line;done` This works also: $ var="$(bash -c 'for ((i=0;i<$#;i++));do echo line; done')" As well than this one: $ var="$(for ((i=0;i<${#};i++));do echo line;done)" Than this one: $ var="$(for ((i=0;i<"$#";i++));do echo line;done)" IRC #bash on freenode 02/12/2016 11:13:19 <Soliton> then i guess the math context is not parsed correctly. that seems odd. 02/12/2016 11:27:57 <mvdw> If you reassign $# to a different variable beforehand it works as well. 02/12/2016 11:36:42 <Soliton> looks to me like a parser failure that reads it as a comment start. <Soliton> doesn't matter what you write after it. it always misses the closing parenthesis. parasite.