[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
command substitution inside parameter expansion inside "for ((;;))"
From: |
Stephane Chazelas |
Subject: |
command substitution inside parameter expansion inside "for ((;;))" |
Date: |
Wed, 15 Nov 2017 10:13:13 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
Hello,
$ bash -c 'for ((i = 0; $(echo 0); i++)); do echo x; done'
(OK)
$ bash -c 'for ((i = 0; ${x-`echo 0`}; i++)); do echo x; done'
(OK)
$ bash -c 'for ((i = 0; ${x-$(echo 0)}; i++)); do echo x; done'
bash: -c: line 0: syntax error near unexpected token `newline'
bash: -c: line 0: `for ((i = 0; ${x-$(echo 0)}; i++)); do echo x; done'
It's the same for ${x#$(echo 0)}.
I also noticed that cmd was not run in ${x#`cmd`} if x happens
to be empty (it's also the case in dash and ksh93 though only if
x is unset; zsh, mksh and yash are fine)
$ bash --version
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
--
Stephane
- command substitution inside parameter expansion inside "for ((;;))",
Stephane Chazelas <=