Hi,
How is the parser supposed to know that the closing parenthesis in */)
is supposed to match the opening $( or not?
This should work, though:
foo=$(while true; do case $HOME in (/*) echo abs ;; esac; done)
Best,
- GG.
On 11/01/2017 12:04 PM, Kjetil Torgrim Homme wrote:
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/opt/bash/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g -O2
-Wno-parentheses -Wno-format-security
uname output: Linux scribus.ms.redpill-linpro.com 4.11.12-200.fc25.x86_64 #1
SMP Fri Jul 21 16:41:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu
Bash Version: 4.4
Patch Level: 12
Release Status: release
Description:
I was bitten by earlier iterations of case selectors prematurely ending
an $()
and my actual problem has been patched in the newest release (thanks!). I came
across a
degenerate case in my testing, though.
Repeat-By:
foo=$(while true; do case $HOME in /*) echo abs ;; esac; done)
bash: syntax error near unexpected token `;;'
It works if you replace "true" with "false", or even with ":" (in which
case it
loops endlessly as it should)
Workaround:
Use backticks, or don't write degenerate code.