[pve-devel] [PATCH kernel-meta 10/10] efiboot: guard against grep returning non-zero

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Jul 12 15:16:51 CEST 2019


which would trigger 'set -e', instead of continuing with correct (empty)
strings.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 bin/pve-efiboot-tool     | 4 ++--
 efiboot/functions        | 3 +--
 efiboot/pve-auto-removal | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/bin/pve-efiboot-tool b/bin/pve-efiboot-tool
index 3abeb8e..be56a81 100755
--- a/bin/pve-efiboot-tool
+++ b/bin/pve-efiboot-tool
@@ -240,8 +240,8 @@ list_kernels() {
 	boot_kernels="$(boot_kernel_list)"
 
 	if [ -e "$MANUAL_KERNEL_LIST" ]; then
-		manual_kernels="$(echo "$boot_kernels" | grep -Fx -f "$MANUAL_KERNEL_LIST")"
-		boot_kernels="$(echo "$boot_kernels" | grep -Fxv -f "$MANUAL_KERNEL_LIST")"
+		manual_kernels="$(echo "$boot_kernels" | grep -Fx -f "$MANUAL_KERNEL_LIST" || true)"
+		boot_kernels="$(echo "$boot_kernels" | grep -Fxv -f "$MANUAL_KERNEL_LIST" || true)"
 	fi
 
 	if [ -z "$manual_kernels" ]; then
diff --git a/efiboot/functions b/efiboot/functions
index 8c473a4..a179713 100755
--- a/efiboot/functions
+++ b/efiboot/functions
@@ -67,8 +67,7 @@ kernel_keep_versions() {
 boot_kernel_list() {
 	list="$(kernel_keep_versions "$@")"
 
-	echo "$list" | grep -E '^[^ ]+-pve'
-
+	echo "$list" | grep -E '^[^ ]+-pve' || true
 }
 
 warn() {
diff --git a/efiboot/pve-auto-removal b/efiboot/pve-auto-removal
index 8aba624..7b21ec4 100755
--- a/efiboot/pve-auto-removal
+++ b/efiboot/pve-auto-removal
@@ -26,7 +26,7 @@ generate_apt_config() {
 		cat <<-EOF
 		/* Debug information:
 		# dpkg list:
-		$(dpkg -l | grep 'pve-kernel')
+		$(dpkg -l | grep -F 'pve-kernel' || true)
 		# list of installed kernel packages:
 		$kernels
 		*/
-- 
2.20.1





More information about the pve-devel mailing list