AW: Question on udhcpc script

depsterr depsterr at protonmail.com
Mon Feb 1 10:37:12 UTC 2021


worth noting that
if ! [ -z "$(ip -6 route list | grep default)" ]; then
is equivalent to
if ip -6 route list | grep -q default; then
which doesnt invoke a subshell

-------- Original Message --------
On Feb 1, 2021, 11:33, Walter Harms < wharms at bfs.de> wrote:
hello,
indeed that looks wrong:
it would be easy to invert but i have no setup to test.
can you do that ?
just change:
if [ -z "$(ip -6 route list | grep default)" ]; then
into
if ! [ -z "$(ip -6 route list | grep default)" ]; then
(note the ! here)
re,
wh
________________________________________
Von: busybox <busybox-bounces at busybox.net> im Auftrag von Bhattiprolu RaviKumar <ravikumar.bhattiprolu at gmail.com>
Gesendet: Montag, 1. Februar 2021 10:36:02
An: busybox at busybox.net
Betreff: Question on udhcpc script
All,
We are using busybox to get DHCPv6 address. However, I am bit confused on the part of the script /etc/udhcpc.d/50default:
wait_for_ipv6_default_route() {
printf "Waiting for IPv6 default route to appear"
while [ $IF_WAIT_DELAY -gt 0 ]; do
if [ -z "$(ip -6 route list | grep default)" ]; then
printf "\n"
return
fi
sleep 1
printf "."
: $((IF_WAIT_DELAY -= 1))
done
printf " timeout!\n"
}
The print says "Waiting for IPv6 default route to appear". However the if statement is checking for "$(ip -6 route list | grep default)"to be null (-z check) which means default route is not present.
In our case, after DHCP, default route gets setup and "$(ip -6 route list | grep default)"returns an entry starting with default and since check is -z, it continues in the loop and finally prints "timeout".
I am confused here. Am I missing something here?
regards,
Ravi
_______________________________________________
busybox mailing list
busybox at busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20210201/eed769b4/attachment-0001.html>


More information about the busybox mailing list