bug-bash
[Top][All Lists]
Advanced

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

Random parser error of $() when there is a case inside


From: Luiz Angelo Daros de Luca
Subject: Random parser error of $() when there is a case inside
Date: Fri, 04 Dec 2015 18:25:15 +0000

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.2 -L/home/abuild/rpmbuild/BUILD/bash-4.2/../readline-6.2
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu' -DCONF_VE
NDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -fmessage-length=0 -
grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g  -D_GNU_SOURCE -DRECY
CLES_PIDS -Wall -g -Wuninitialized -Wextra -Wno-unprototyped-calls -Wno-switch-enum -Wno-unused-variable -Wno-unused-parameter -ftree-loop
-linear -pipe -DBNC382214=0 -DIMPORT_FUNCTIONS_DEF=0 -fprofile-use
uname output: Linux tresc031501 3.16.7-29-default #1 SMP Fri Oct 23 00:46:04 UTC 2015 (6be6a97) x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux-gnu

Bash Version: 4.2
Patch Level: 53
Release Status: release

Description:
While writing a script, I faced a random parser error with code like

A=$(
...
case b in
c)
...
esac 
...
)

Minor changes like renaming a variable skips the problem. It seems that the parser gets confused in some cases.

Repeat-By:

Run the script bellow. The first block work. If I change the b name to bb, it fails! If I switch from $() to ``, it works:

A=$(
       for b; do
                       case c in
                       d)
                               echo 123
                       ;;
                       esac
       done
)
echo OK

# Changed $() to ``
A=`
       for bb; do
                       case c in
                       d)  
                               echo 123
                       ;;
                       esac
       done
`
echo OK

# changed the name from b to bb!!
A=$(
       for bb; do
                       case c in
                       d) #<- something with this  
                               echo 123 #<- and this runs!! check stdout!
                       ;;
                       esac
       done
)
echo Fail


OUTPUT:

OK
OK
a.sh: command substitution: line 33: syntax error: unexpected end of file
123
a.sh: line 30: syntax error near unexpected token `;;'
a.sh: line 30: `                       ;;'


--

Luiz Angelo

--

Luiz Angelo Daros de Luca


reply via email to

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