Bug#473156: [checks/scripts] dash now supports $((cnt+1))

2008-04-04 Thread Adam D. Barratt
On Fri, 2008-03-28 at 19:23 +, Adam D. Barratt wrote:
> On Fri, 2008-03-28 at 11:59 -0700, Russ Allbery wrote:
> > "Adam D. Barratt" <[EMAIL PROTECTED]> writes:
> > 
> > > As far as I can see, it *is* in POSIX, which is what persuaded Herbert
> > > to (albeit slowly) add it to dash.
> > 
> > Oh!  Then the comment now makes sense to me, and by all means we should
> > remove this check.  Thank you very much for this; I hadn't realized that
> > was a standard feature.
> 
> It wasn't. Having just checked, SUS2 only requires $(($var+1)); $((var
> +1)) is an SUS3 addition.

In fact, having found a copy of the older SUSv3 editions, it's even more
recent.

SUSv3 2003 (i.e. IEEE 1003.1-2003) does not contain the requirement for
$(($var)) and $((var)) to be equivalent; that was added in the 2004
revision. As policy refers to the latter, however, that shouldn't be a
problem.

Regards,

Adam



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#473156: [checks/scripts] dash now supports $((cnt+1))

2008-03-28 Thread Adam D. Barratt
On Fri, 2008-03-28 at 11:59 -0700, Russ Allbery wrote:
> "Adam D. Barratt" <[EMAIL PROTECTED]> writes:
> 
> > As far as I can see, it *is* in POSIX, which is what persuaded Herbert
> > to (albeit slowly) add it to dash.
> 
> Oh!  Then the comment now makes sense to me, and by all means we should
> remove this check.  Thank you very much for this; I hadn't realized that
> was a standard feature.

It wasn't. Having just checked, SUS2 only requires $(($var+1)); $((var
+1)) is an SUS3 addition.

Adam



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#473156: [checks/scripts] dash now supports $((cnt+1))

2008-03-28 Thread Russ Allbery
"Adam D. Barratt" <[EMAIL PROTECTED]> writes:

> As far as I can see, it *is* in POSIX, which is what persuaded Herbert
> to (albeit slowly) add it to dash.

Oh!  Then the comment now makes sense to me, and by all means we should
remove this check.  Thank you very much for this; I hadn't realized that
was a standard feature.

-- 
Russ Allbery ([EMAIL PROTECTED])   



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#473156: [checks/scripts] dash now supports $((cnt+1))

2008-03-28 Thread Adam D. Barratt
On Fri, 2008-03-28 at 11:31 -0700, Russ Allbery wrote:
> "Adam D. Barratt" <[EMAIL PROTECTED]> writes:
[...]
> > dash (finally) gained support for the shell arithmetic construct "$((var
> > +1))" with the upload of 0.5.4-3 in December 2007 (see #329025).
> >
> > As lenny contains a version of dash with the support, I've attached a
> > patch removing the corresponding test from the bashisms section of
> > checks/scripts.
> 
> dash is not the metric for bashisms, though.  If it's not in POSIX and
> isn't listed as an exception in Policy 10.4, it's not allowed for /bin/sh
> scripts.

I realise that. :-) The comment against the check does say "doesn't work
in dash", although I realise that's merely informative.

> Do you think we should add this as an additional exception?

As far as I can see, it *is* in POSIX, which is what persuaded Herbert
to (albeit slowly) add it to dash.


2.6.4 Arithmetic Expansion
Arithmetic expansion provides a mechanism for evaluating an arithmetic
expression and substituting its value. The format for arithmetic
expansion shall be as follows:

$((expression))
[...]
Next, the shell shall treat this as an arithmetic expression and
substitute the value of the expression. The arithmetic expression shall
be processed according to the rules given in Arithmetic Precision and
Operations , with the following exceptions:

  * Only signed long integer arithmetic is required.
[...]
If the shell variable x contains a value that forms a valid integer
constant, then the arithmetic expansions "$((x))" and "$(($x))" shall
return the same value.


My reading of the above is that "$((var+1))" is valid and that the
comment against the check was correct - i.e. it's not a bashism at all,
but was being checked for simply because dash did not correctly support
the syntax despite it being permitted by POSIX with no extensions.

As a further data point, posh supports both $((var+1)) and $((var=1)).

Adam



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#473156: [checks/scripts] dash now supports $((cnt+1))

2008-03-28 Thread Russ Allbery
"Adam D. Barratt" <[EMAIL PROTECTED]> writes:

> Package: lintian
> Version: 1.23.46
> Severity: wishlist
> Tags: patch
>
> dash (finally) gained support for the shell arithmetic construct "$((var
> +1))" with the upload of 0.5.4-3 in December 2007 (see #329025).
>
> As lenny contains a version of dash with the support, I've attached a
> patch removing the corresponding test from the bashisms section of
> checks/scripts.

dash is not the metric for bashisms, though.  If it's not in POSIX and
isn't listed as an exception in Policy 10.4, it's not allowed for /bin/sh
scripts.

Do you think we should add this as an additional exception?

-- 
Russ Allbery ([EMAIL PROTECTED])   



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#473156: [checks/scripts] dash now supports $((cnt+1))

2008-03-28 Thread Adam D. Barratt
Package: lintian
Version: 1.23.46
Severity: wishlist
Tags: patch

Hi,

dash (finally) gained support for the shell arithmetic construct "$((var
+1))" with the upload of 0.5.4-3 in December 2007 (see #329025).

As lenny contains a version of dash with the support, I've attached a
patch removing the corresponding test from the bashisms section of
checks/scripts.

Regards,

Adam
--- scripts.orig	2008-03-25 19:04:56.0 +
+++ scripts	2008-03-28 18:15:03.0 +
@@ -572,7 +572,6 @@
 		  '(<\&|>\&)\s*((-|\d+)[^\s;|\)\`&]|[^-\d])', # should be >word 2>&1
 		  '\[\[(?!:)',		   # alternative test command
 		  '(?:^|\s+)select\s+\w+', # 'select' is not POSIX
-		  '\$\(\([A-Za-z]',	   # cnt=$((cnt + 1)) does not work in dash
 		  '(?:^|\s+)echo\s+-e',# echo -e
 		  '(?:^|\s+)exec\s+-[acl]',# exec -c/-l/-a name
 		  '(?:^|\s+)let\s',	   # let ...