bug-bash
[Top][All Lists]
Advanced

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

Parse error with consecutive case statements inside $()


From: Christian Franke
Subject: Parse error with consecutive case statements inside $()
Date: Tue, 29 Mar 2016 19:43:56 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39

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]