standards/52972: /bin/sh arithmetic not POSIX compliant

Jens Schweikhardt schweikh at schweikhardt.net
Sun Jun 22 13:50:06 PDT 2003


The following reply was made to PR standards/52972; it has been noted by GNATS.

From: Jens Schweikhardt <schweikh at schweikhardt.net>
To: Wartan Hachaturow <wart at tepkom.ru>
Cc: GNATS Bug Followup <bug-followup at FreeBSD.org>
Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant
Date: Sun, 22 Jun 2003 22:43:27 +0200

 Wartan,
 
 [please always cc to <bug-followup at FreeBSD.org> with the subject left as
 is (like in this mail), so GNATS can add your comments to the audit
 trail. Thanks!]
 
 On Mon, Jun 23, 2003 at 12:21:58AM +0400, Wartan Hachaturow wrote:
 # Hello.
 # 
 # I think I may try to fix this bug, but for now I've failed to
 # find a precise line in SUS that requires this ( $((a+1)) vs $(($a+1)) )
 # kind of arithmetic evaluation.
 # I understand that in order to have "+=" operators, for example,
 # we've got to have some way to use a variable itself, not substituted
 # by its value, but still..
 # Perhaps someone may point me to the exact part of SUS that describes 
 # this particular thing?
 
 It's in "Token Recognition"
 
  [...]
 
   If the current character is an unquoted '$' or '`' , the shell shall
   identify the start of any candidates for parameter expansion (
   Parameter Expansion ), command substitution ( Command Substitution ),
   or arithmetic expansion ( Arithmetic Expansion ) from their
   introductory unquoted character sequences: '$' or "${" , "$(" or '`' ,
   and "$((" , respectively. The shell shall read sufficient input to
   determine the end of the unit to be expanded (as explained in the
   cited sections). While processing the characters, if instances of
   expansions or quoting are found nested within the substitution, the
   shell shall recursively process them in the manner specified for the
   construct that is found. The characters found from the beginning of
   the substitution to its end, allowing for any recursion necessary to
   recognize embedded constructs, shall be included unmodified in the
   result token, including any embedded or enclosing substitution
   operators or quotes. The token shall not be delimited by the end of
   the substitution.
 
 
 The recursive processing requires that $(($a+1)) needs to undergo
 parameter expansion within $(()).
 
 Regards,
 
 	Jens
 -- 
 Jens Schweikhardt http://www.schweikhardt.net/
 SIGSIG -- signature too long (core dumped)


More information about the freebsd-standards mailing list