Avoid duplicated echo / cut call, this make it easier to clean up code in later commits.
Signed-off-by: Kairui Song kasong@redhat.com --- dracut-module-setup.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 53abdc75..768026d3 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -523,9 +523,14 @@ kdump_get_ip_route()
kdump_get_ip_route_field() { - if `echo $1 | grep -q $2`; then - echo ${1##*$2} | cut -d ' ' -f1 + local _str=$1 + + if [[ "$_str" == *" $2 "* ]]; then + _str="${_str##*$2 }" + _str="${_str%% *}" fi + + echo "$_str" }
kdump_get_remote_ip()