From 7f35cdc86a09f1b0a1a5ce5241fe9bfc6a0fa0ca Mon Sep 17 00:00:00 2001 From: caem Date: Fri, 10 May 2024 13:15:31 +0200 Subject: [PATCH] Fix xargs misbehaving when there are no packages Adding the -r argument to xargs makes it not run for no reason when there are no packages to trim spaces from. Otherwise it'd always run at least once and sometimes misbehave. --- zypper_autoremove.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zypper_autoremove.bash b/zypper_autoremove.bash index d06fab5..b0a75f7 100755 --- a/zypper_autoremove.bash +++ b/zypper_autoremove.bash @@ -7,7 +7,7 @@ table_start=$(echo "$package_list" | grep -n "S | Repository | Name"| gawk '{pri unneeded_packages=() while IFS= read -r package; do - package="$(echo "$package"| awk -F '|' '{ print $3 }' | xargs)" + package="$(echo "$package"| awk -F '|' '{ print $3 }' | xargs -r)" unneeded_packages+=("$package") done < <(echo "$package_list" | tail -n+$((table_start+2)))