Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/hv: reduce resouce usage in hv_get_dns_info helper

Remove the usage of cat. Replace the shell process with awk with 'exec'.
Also use a generic shell because no bash specific features will be used.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Wei Liu <wei.liu@kernel.org>
Link: https://lore.kernel.org/r/20241202120432.21115-1-olaf@aepfle.de
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <20241202120432.21115-1-olaf@aepfle.de>

authored by

Olaf Hering and committed by
Wei Liu
a4d024fe 07dfa6e8

+2 -2
+2 -2
tools/hv/hv_get_dns_info.sh
··· 1 - #!/bin/bash 1 + #!/bin/sh 2 2 3 3 # This example script parses /etc/resolv.conf to retrive DNS information. 4 4 # In the interest of keeping the KVP daemon code free of distro specific ··· 10 10 # this script can be based on the Network Manager APIs for retrieving DNS 11 11 # entries. 12 12 13 - cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }' 13 + exec awk '/^nameserver/ { print $2 }' /etc/resolv.conf 2>/dev/null