Skip to contentSkip to conversation

wait_for_if_up fix

PATCH In review Dave Young 2 participants 3 messages Feb 15, 2012 – Feb 16, 2012 2 messages not in the archive

lore
Share & tools
lore

Dave Young

author
#0 lore raw

PATCH 2/3 wait_for_if_up fix

wait_for_if_up will always return 0, fix it by change to use =~ to check if link state is up

---
 modules.d/99base/dracut-lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
modules.d/99base/dracut-lib.sh +1 -1
index 6b70adf..85d4925 100755
@@ -385,7 +385,7 @@ wait_for_if_up() {
     local cnt=0
     while [ $cnt -lt 200 ]; do
         li=$(ip link show $1)
-        [ -z "${li##*state UP*}" ] && return 0
+        [[ "$li" =~ "state UP" ]] && return 0
         sleep 0.1
         cnt=$(($cnt+1))
     done
Signature · 1 line
1.7.7.5
#2 lore raw
In reply to a message not in the archive

Am 15.02.2012 07:40, schrieb Dave Young:

Quoted 13 lines

wait_for_if_up will always return 0, fix it by change to use =~ to check if link state is up

---
 modules.d/99base/dracut-lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
modules.d/99base/dracut-lib.sh +0 -0
index 6b70adf..85d4925 100755

modules.d/99base/dracut-lib.sh wait_for_if_up() { · line 391

Quoted 8 lines
modules.d/99base/dracut-lib.sh +1 -1
@@ -385,7 +385,7 @@ wait_for_if_up() {
     local cnt=0
     while [ $cnt -lt 200 ]; do
         li=$(ip link show $1)
-        [ -z "${li##*state UP*}" ] && return 0
+        [[ "$li" =~ "state UP" ]] && return 0
         sleep 0.1
         cnt=$(($cnt+1))
     done

This is not posix shell compliant.

$ PS1="$ " dash
$ li="my state DOWN test"
$ [ -z "${li##*state UP*}" ] && echo OK
$ li="my state UP test"
$ [ -z "${li##*state UP*}" ] && echo OK
OK
$

works for me

author
#4 lore raw
In reply to a message not in the archive
Quoted 34 lines · Harald Hoyer

Am 15.02.2012 07:40, schrieb Dave Young:

Quoted 13 lines

wait_for_if_up will always return 0, fix it by change to use =~ to check if link state is up

---
 modules.d/99base/dracut-lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
modules.d/99base/dracut-lib.sh +0 -0
index 6b70adf..85d4925 100755

modules.d/99base/dracut-lib.sh wait_for_if_up() { · line 391

Quoted 8 lines
modules.d/99base/dracut-lib.sh +1 -1
@@ -385,7 +385,7 @@ wait_for_if_up() {
     local cnt=0
     while [ $cnt -lt 200 ]; do
         li=$(ip link show $1)
-        [ -z "${li##*state UP*}" ] && return 0
+        [[ "$li" =~ "state UP" ]] && return 0
         sleep 0.1
         cnt=$(($cnt+1))
     done

This is not posix shell compliant.

$ PS1="$ " dash
$ li="my state DOWN test"
$ [ -z "${li##*state UP*}" ] && echo OK
$ li="my state UP test"
$ [ -z "${li##*state UP*}" ] && echo OK
OK
$
Quoted 1 line

works for me

Thanks for comment, above work for me as well.
Actually I tested with an non-exist nic. In that case $li will be nul

Signature · 2 lines
Thanks
Dave