bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parse error with consecutive case statements inside $()


From: Piotr Grzybowski
Subject: Re: Parse error with consecutive case statements inside $()
Date: Thu, 31 Mar 2016 11:07:18 +0200

Hello Christian,
Hi all,

 confirmed. this is due to the fact, that the second case does not get tflags |= LEX_INCASE; in parse_comsub which returns prematurely.
 when I give up on trying to fix that I will let you know :)

cheers,
pg


On Tue, Mar 29, 2016 at 7:43 PM, Christian Franke <Christian.Franke@t-online.de> wrote:
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: cygwin
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='cygwin' -DCONF_MACHTYPE='i686-pc-cygwin' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DRECYCLES_PIDS   -I. -I/usr/src/bash-4.3.42-4.i686/src/bash-4.3 -I/usr/src/bash-4.3.42-4.i686/src/bash-4.3/include -I/usr/src/bash-4.3.42-4.i686/src/bash-4.3/lib  -DWORDEXP_OPTION -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/bash-4.3.42-4.i686/build=/usr/src/debug/bash-4.3.42-4 -fdebug-prefix-map=/usr/src/bash-4.3.42-4.i686/src/bash-4.3=/usr/src/debug/bash-4.3.42-4
uname output: CYGWIN_NT-6.1-WOW Alien2 2.4.1(0.293/5/3) 2016-01-24 11:24 i686 Cygwin
Machine Type: i686-pc-cygwin

Bash Version: 4.3
Patch Level: 42
Release Status: release

Description:
If consecutive case statements are inside of $(...), the parser misinterprets first ')' from second case statement as the end of command substitution.

The possibly related patch bash43-042 is already included in this version.


Repeat-By:

$ cat bug.sh
x=$(
  case 1 in
    1) echo 1
  esac
  case 2 in
    2) echo 2
  esac
)
echo "$x"


$ bash -xv bug.sh
x=$(
  case 1 in
    1) echo 1
  esac
  case 2 in
    2) echo 2
bug.sh: command substitution: line 13: syntax error: unexpected end of file
bug.sh: line 7: syntax error near unexpected token `esac'
bug.sh: line 7: ` esac'


$ dash bug.sh
1
2


Workarounds:
- append semicolon behind first 'esac', or
- insert any command line between the case statements, or
- use `...` instead of $(...)


--
Christian Franke




reply via email to

[Prev in Thread] Current Thread [Next in Thread]