tech-userlevel archive

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

Re: sh weirdness?



On Fri, 17 Sep 2010, der Mouse wrote:
> sh -n -c 'case foo in (bar | baz) echo one; esac' [doesn't work in 1.4T]
> Based on the context in which I found it, it looks as though
> the case above is probably semantically equivalent to
> "case foo in bar|baz) echo one;; esac"

Yes, it is semantically equivalent.  POSIX added an optional
"(" to match the compulsory ")" delimiting patterns in a case
statement, and made the ";;" optional for the last branch of
a case statement.

Search for "Case Conditional Construct" in
<http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html>
but there seems to be a mistake in the syntax under "The format
for the if construct is as follows", where it shows the ";;" to be
compulsory after the first item, even if there is exactly one item.

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index