From: Jason A. Donenfeld Date: Mon, 24 Jul 2017 21:22:10 +0000 (+0200) Subject: wg-quick: do not use grep X-Git-Tag: v1.0.20191226~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41e50edbe5fd5c4a34b27830907f3e49114e8695;p=thirdparty%2Fwireguard-tools.git wg-quick: do not use grep Signed-off-by: Jason A. Donenfeld --- diff --git a/src/wg-quick.bash b/src/wg-quick.bash index b1fb435..d7e7d68 100755 --- a/src/wg-quick.bash +++ b/src/wg-quick.bash @@ -226,7 +226,7 @@ cmd_up() { done set_mtu up_if - for i in $(wg show "$INTERFACE" allowed-ips | grep -Po '(?<=[\t ])[0-9.:/a-f]+' | sort -nr -k 2 -t /); do + for i in $(while read -r _ i; do for i in $i; do [[ $i =~ ^[0-9a-z:.]+/[0-9]+$ ]] && echo "$i"; done; done < <(wg show "$INTERFACE" allowed-ips) | sort -nr -k 2 -t /); do [[ $(ip route get "$i" 2>/dev/null) == *dev\ $INTERFACE\ * ]] || add_route "$i" done execute_hook "$POST_UP"