Document optional open parenthesis for case patterns.
PATCH 1/1 Document optional open parenthesis for case patterns.
Hi,
while inspecting some dash scripts on my system, I was surprised to see that some of them use an open parenthesis at the beginning of case patterns while that's not mentioned in the manpage. Dash currently is fine with and without that parenthesis (parser.c:413). The attached patch documents this feature.
Philipp
src/dash.1 +6 -1
@@ -663,7 +663,7 @@ These are implemented as builtin commands. The syntax of the case command is .Bd -literal -offset indent case word in -pattern) list ;; +[(]pattern) list ;; \&... esac .Ed
@@ -673,6 +673,11 @@ The pattern can actually be one or more patterns (see described later), separated by .Dq \*(Ba characters. +The +.Do +( +.Dc +character before the pattern is optional. .Ss Grouping Commands Together Commands may be grouped by writing either .Pp
Quoted 4 lines · Philipp Weis
while inspecting some dash scripts on my system, I was surprised to see that some of them use an open parenthesis at the beginning of case patterns while that's not mentioned in the manpage. Dash currently is fine with and without that parenthesis (parser.c:413).
BTW, This feature is a workaround:
Without the left paren, several shells¹ are confused with "case" inside $( ), because now the parens are not "balanced" anymore. Although dash doesn't need this (in fact any ash variant), it was added ('99) for reasons of script portability. Another benefit is easy searching for matching parens in editors.
¹ bash pre-4, ksh88, pdksh-variants
Quoted 7 lines · Philipp Weis
Hi,
while inspecting some dash scripts on my system, I was surprised to see that some of them use an open parenthesis at the beginning of case patterns while that's not mentioned in the manpage. Dash currently is fine with and without that parenthesis (parser.c:413). The attached patch documents this feature.
Patch applied. Thanks!
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt