]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Tools.pm
print_text_table: handle undefined values in comparision
[pve-common.git] / src / PVE / Tools.pm
index f02c0ae3a5acce5bec19cbb1e6906309410f65e5..f6b18f16b7c34f519edbd97dc9dd49f28816aa42 100644 (file)
@@ -1766,4 +1766,13 @@ sub mount($$$$$) {
     );
 }
 
+sub safe_compare {
+    my ($left, $right, $cmp) = @_;
+
+    return 0 if !defined($left) && !defined($right);
+    return -1 if !defined($left);
+    return 1 if !defined($right);
+    return $cmp->($left, $right);
+}
+
 1;