bug-bash
[Top][All Lists]
Advanced

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

Re: $(case x in x)...


From: Eric Blake
Subject: Re: $(case x in x)...
Date: Mon, 02 Jan 2006 22:14:38 +0000

> Eric> $ k=$(case x in (x) :; esac)
> Huh, they only taught us ) in school.
> Is () since Bell Labs days too?

POSIX requires shells to support case x in (x), but older
bourne shells do not support this newer syntax.  That is
probably why you were not taught it; if I understand
correctly, it was invented in ksh, then standardized by
POSIX, which is why bash now has it.  At any rate,
several platforms, including Solaris' /bin/sh, still do not
parse ( in case patterns even today, so it is certainly
not portable if you don't have access to a POSIX shell.

> P.S. I didn't test <<\EOF with ")" itself as the EOF marker,
> <<\( maybe. You can... Reply-To: bug-bash@gnu.org, jidanni@jidanni.org

Indeed, this points out another (probably related) parsing
problem in bash 3.1:

Buggy (here-doc delimiter treated as $() closer):
$ echo $(
> cat << ')'
> hello
> )
hello

Expected:
$ echo $(
> cat << ')'
> hello
> )
> )
hello

--
Eric Blake




reply via email to

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