]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
scripts/runqemu-ifup: Fix 10 or more tap devices
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 19 Jun 2023 14:46:37 +0000 (15:46 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 19 Jun 2023 14:46:45 +0000 (15:46 +0100)
The use of sort means that tap10 and tap1 don't sort correctly. Tweak
the shell expression to correctly handle numbers of tap devices of 10
or more.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/runqemu-ifup

index e3aa16c97df42e996367ba5b9142e9b297b6db76..5dc765dee826b73f47eea9772d64a11af9f54d18 100755 (executable)
@@ -38,7 +38,7 @@ USERID="-u $1"
 GROUP="-g $2"
 
 if taps=$(ip tuntap list 2>/dev/null); then
-       tap_no=$(( $(echo "$taps" |sort -r |sed 's/^tap//; s/:.*//; q') + 1 ))
+       tap_no=$(( $(echo "$taps" |cut -f 1 -d ":" | sed 's/tap//g' | sort -rn | head -n 1) + 1 ))
        ip tuntap add tap$tap_no mode tap group $2 && TAP=tap$tap_no
 fi