Debian Bug report logs -
#86397
[commented upstream] `case' inside of `$( )' command substitution gives syntax error
Reported by: Jeff Sheinberg <jeff@bsrd.net>
Date: Sat, 17 Feb 2001 20:03:02 UTC
Severity: normal
Tags: upstream
Merged with 225550
Found in versions 2.04-9, 2.05a-11
Fixed in version 5.0-6
Done: Gioele Barabucci <gioele@svario.it>
Bug is archived. No further changes may be made.
Forwarded to chet@po.cwru.edu
Toggle useless messages
Report forwarded to debian-bugs-dist@lists.debian.org, Matthias Klose <doko@debian.org>:
Bug#86397; Package bash.
(full text, mbox, link).
Acknowledgement sent to Jeff Sheinberg <jeffsh@erols.com>:
New Bug report received and forwarded. Copy sent to Matthias Klose <doko@debian.org>.
(full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: bash
Version: 2.04-9
Severity: normal
Hi,
The following typescript shows that bash reports a syntax error
for a `case' statement inside of the `$( )' form of command
substitution. I looked at the SUSv2 docs, and according to my
reading, this should be a legal shell construct.
Both ash and ksh93 handle this correctly, while bash and pdksh do
not. Also note that the same `case' inside of either the old
style (back-quoted) command substitution or inside of a sub-shell
`( )' _is_ handled correctly by bash.
Note too that if the case selector has the leading (optional) `(',
then bash will handle the otherwise same `case' correctly.
Here are some notes regarding the typescript,
1. !137 - bash gives syntax error, new style $( ).
2. !138 - ok with (2) case selector, new style $( ).
3. !139 - ok with 2) case selector, old style ` `.
4. !140 - ok with 2) case selector, sub-shell ( ).
5. !141 - ok with (2) case selector, sub-shell ( ).
Here is the typescript itself,
137 jeff ~ $ do_shells 'aa=$( case 1 in 2) ;; esac )'
========================================================================
>> aa=$( case 1 in 2) ;; esac ) <<
sh: line 1: syntax error near unexpected token `;'
sh: line 1: `aa=$( case 1 in 2) ;; esac )'
-- sh -- exit status 2
-- ash --
bash: line 1: syntax error near unexpected token `;'
bash: line 1: `aa=$( case 1 in 2) ;; esac )'
-- bash -- exit status 2
pdksh: <stdin>[1]: syntax error: `;;' unexpected
-- pdksh -- exit status 1
-- ksh93 --
138 jeff ~ $ do_shells 'aa=$( case 1 in (2) ;; esac )'
========================================================================
>> aa=$( case 1 in (2) ;; esac ) <<
-- sh --
-- ash --
-- bash --
-- pdksh --
-- ksh93 --
139 jeff ~ $ do_shells 'aa=` case 1 in 2) ;; esac `'
========================================================================
>> aa=` case 1 in 2) ;; esac ` <<
-- sh --
-- ash --
-- bash --
-- pdksh --
-- ksh93 --
140 jeff ~ $ do_shells '( case 1 in 2) ;; esac )'
========================================================================
>> ( case 1 in 2) ;; esac ) <<
-- sh --
-- ash --
-- bash --
-- pdksh --
-- ksh93 --
141 jeff ~ $ do_shells '( case 1 in (2) ;; esac )'
========================================================================
>> ( case 1 in (2) ;; esac ) <<
-- sh --
-- ash --
-- bash --
-- pdksh --
-- ksh93 --
Thanks,
--
Jeff Sheinberg <jeffsh@erols.com>
-- System Information
Debian Release: woody/testing
Kernel Version: Linux eden-hda7.my.local 2.2.18 #2 Wed Feb 7 08:10:35 EST 2001 i586 unknown
Versions of the packages bash depends on:
ii base-files 2.2.6 Debian base system miscellaneous files
ii libc6 2.2.1-1 GNU C Library: Shared libraries and Timezone
ii libncurses5 5.0-6.0potato1 Shared libraries for terminal handling
ii libreadline4 4.1-4 GNU readline and history libraries, run-time
--- Begin /etc/bash.bashrc (modified conffile)
. /etc/local/1.sh "/etc/bash.bashrc"
shopt -s checkwinsize
--- End /etc/bash.bashrc
Information forwarded to debian-bugs-dist@lists.debian.org, Matthias Klose <doko@debian.org>:
Bug#86397; Package bash.
(full text, mbox, link).
Acknowledgement sent to Matthias Klose <doko@cs.tu-berlin.de>:
Extra info received and forwarded to list. Copy sent to Matthias Klose <doko@debian.org>.
(full text, mbox, link).
Message #10 received at 86397@bugs.debian.org (full text, mbox, reply):
Reply of upstream author:
From: Chet Ramey <chet@nike.ins.cwru.edu>
This is a hard problem to fix. I've looked at various ways to do so,
and
it gets very messy when you've got a yacc-based parser.
POSIX.2 noted this situation, and added an optional `(' before the
case pattern, so the parens match. Since most posix-like shells
support it, that is the syntax I recommend.
Changed Bug title.
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Noted your statement that Bug has been forwarded to chet@po.cwru.edu.
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Bug closed, send any further explanations to Jeff Sheinberg <jeffsh@erols.com>
Request was from Jeff Sheinberg <jeffsh@localnet.com>
to control@bugs.debian.org.
(full text, mbox, link).
Bug reopened, originator set to Jeff Sheinberg <jeffsh@localnet.com>.
Request was from Jeff Sheinberg <jeffsh@localnet.com>
to control@bugs.debian.org.
(full text, mbox, link).
Bug closed, send any further explanations to Jeff Sheinberg <jeffsh@localnet.com>
Request was from Jeff Sheinberg <jeff@bsrd.net>
to control@bugs.debian.org.
(full text, mbox, link).
Bug reopened, originator set to Jeff Sheinberg <jeff@bsrd.net>.
Request was from Jeff Sheinberg <jeff@bsrd.net>
to control@bugs.debian.org.
(full text, mbox, link).
Tags added: upstream
Request was from Matthias Klose <doko@cs.tu-berlin.de>
to control@bugs.debian.org.
(full text, mbox, link).
Reply sent
to Gioele Barabucci <gioele@svario.it>:
You have taken responsibility.
(Mon, 15 Apr 2024 10:57:02 GMT) (full text, mbox, link).
Notification sent
to Jeff Sheinberg <jeff@bsrd.net>:
Bug acknowledged by developer.
(Mon, 15 Apr 2024 10:57:02 GMT) (full text, mbox, link).
Message #31 received at 86397-done@bugs.debian.org (full text, mbox, reply):
Version: 5.0-6
On Sat, 17 Feb 2001 14:56:14 -0500 (EST) Jeff Sheinberg
<jeffsh@erols.com> wrote:
> The following typescript shows that bash reports a syntax error
> for a `case' statement inside of the `$( )' form of command
> substitution. I looked at the SUSv2 docs, and according to my
> reading, this should be a legal shell construct.
>
> 137 jeff ~ $ do_shells 'aa=$( case 1 in 2) ;; esac )'
> ========================================================================
> >> aa=$( case 1 in 2) ;; esac ) <<
> sh: line 1: syntax error near unexpected token `;'
> sh: line 1: `aa=$( case 1 in 2) ;; esac )'
> -- sh -- exit status 2
> -- ash --
> bash: line 1: syntax error near unexpected token `;'
> bash: line 1: `aa=$( case 1 in 2) ;; esac )'
> -- bash -- exit status 2
> pdksh: <stdin>[1]: syntax error: `;;' unexpected
> -- pdksh -- exit status 1
> -- ksh93 --
Hi,
this issue does not seem to affect version 5.0-6 and later of bash.
$ aa=$( case 1 in 2) ;; esac )
$ echo "$aa"
$ aa=$( case 1 in 2) ;; *) echo "else" ;; esac )
$ echo $aa
else
Please reopen this bug if you can still reproduce this issue.
Regards,
--
Gioele Barabucci
Reply sent
to Gioele Barabucci <gioele@svario.it>:
You have taken responsibility.
(Mon, 15 Apr 2024 10:57:03 GMT) (full text, mbox, link).
Notification sent
to Jan Minar <jjminar@fastmail.fm>:
Bug acknowledged by developer.
(Mon, 15 Apr 2024 10:57:03 GMT) (full text, mbox, link).
Bug archived.
Request was from Debbugs Internal Request <owner@bugs.debian.org>
to internal_control@bugs.debian.org.
(Tue, 14 May 2024 07:26:58 GMT) (full text, mbox, link).
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Mon May 20 15:30:33 2024;
Machine Name:
bembo
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.