From: Roy Marples Date: Tue, 21 Apr 2020 13:31:39 +0000 (+0100) Subject: 01-test: Avoid use of grep and sort which might be in /usr X-Git-Tag: v9.1.0~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fefe033492bd4916f3a219401acf6d1ddedc81c;p=thirdparty%2Fdhcpcd.git 01-test: Avoid use of grep and sort which might be in /usr This is a touch more long winded, but is fully shell and the output *should* be identical. --- diff --git a/hooks/01-test b/hooks/01-test index 6732af79..99499425 100644 --- a/hooks/01-test +++ b/hooks/01-test @@ -1,9 +1,37 @@ # Echo the interface flags, reason and message options if [ "$reason" = "TEST" ]; then - set | grep \ - "^\(interface\|pid\|reason\|protocol\|profile\|skip_hooks\)=" | sort - set | grep "^if\(carrier\|flags\|mtu\|wireless\|ssid\)=" | sort - set | grep "^\(new_\|old_\|nd[0-9]*_\)" | sort + # General variables at the top + set | while read line; do + case "$line" in + interface=*|pid=*|reason=*|protocol=*|profile=*|skip_hooks=*) + echo "$line";; + esac + done + # Interface flags + set | while read line; do + case "$line" in + ifcarrier=*|ifflags=*|ifmetric=*|ifmtu=*|ifwireless=*|ifssid=*) + echo "$line";; + esac + done + # Old lease + set | while read line; do + case "$line" in + old_*) echo "$line";; + esac + done + # New lease + set | while read line; do + case "$line" in + new_*) echo "$line";; + esac + done + # Router Advertisements + set | while read line; do + case "$line" in + nd[0-9]*_*) echo "$line";; + esac + done exit 0 fi