Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 391671 - sys-apps/openrc-9999 commit ef1ff1b4: error in init.d/net.lo.in
Summary: sys-apps/openrc-9999 commit ef1ff1b4: error in init.d/net.lo.in
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard: openrc:oldnet
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-23 09:26 UTC by Duncan
Modified: 2013-04-25 23:08 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan 2011-11-23 09:26:05 UTC
openrc-9999.  I'm at commit 815952a65a now, but the problem is in commit ef1ff1b4 by vapier.  Here's the diff-segment in question (from git show):

diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index 66e1945..d647f31 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -115,7 +115,7 @@ _wait_for_carrier()
                        eend 0
                        return 0
                fi
-               timeout=$((${timeout} - 1))
+               : $(( timeout -= 1 ))
                [ "${efunc}" = "einfon" ] && printf "."
        done

@@ -144,9 +144,9 @@ _netmask2cidr()
        local i= len=
        local IFS=.
        for i in $1; do
-               while [ ${i} != "0" ]; do
-                       len=$((${len} + ${i} % 2))
-                       i=$((${i} >> 1))
+               while [ i -ne 0 ]; do
+                       : $(( len += i % 2 ))
+                       : $(( i >>= 1 ))
                done
        done

The problem is line 147:

+               while [ i -ne 0 ]; do

Bash (4.2_p10) errors on that:

[: i: integer expression expected.

A diagnostic echo says $1 is "255 255 255 0" and $i gets the successive integer values 255 255 255 0 as expected.

Apparently, Mike got a bit zealous with his cleanup and in line 147,
s/i/$i/ .   That appears to solve the problem, here.

(I actually switched to -9999 in ordered to be able to check individual git commits when I upgrade.  I scan git whatchanged and git show commits that look interesting.  That commit looked interesting and I actually paused when I saw that $-less variable, but I figured vapier knew way more about bash/shell than I did, so it must work.  Actual usage proved my doubts valid.  He's certainly correct with the commit comment, tho, the rest of that commit DOES make things much more readable. =:^)