]> git.proxmox.com Git - pve-installer.git/blobdiff - Proxmox/Sys/Command.pm
run command: avoid using 1 as special value
[pve-installer.git] / Proxmox / Sys / Command.pm
index cb5fe76e84c6e078ae94d7b95885efb7fbca62fc..ac505c486049a1a640b93c187993649326615d62 100644 (file)
@@ -17,7 +17,10 @@ use Proxmox::UI;
 use base qw(Exporter);
 our @EXPORT_OK = qw(run_command syscmd CMD_FINISHED);
 
-use constant CMD_FINISHED => 1;
+use constant {
+    CMD_RESERVED => 1<<0, # reserve 1 as it's often the default return value of closures
+    CMD_FINISHED => 1<<1,
+};
 
 my sub shellquote {
     my $str = shift;
@@ -78,8 +81,9 @@ sub syscmd {
 #
 # Arguments:
 # * $cmd - The command to run, either a single string or array with individual arguments
-# * $func - Logging subroutine to call, receives both stdout and stderr. Might return CMD_FINISHED
-#           to exit early and ignore the rest of the process output.
+# * $func - Logging subroutine to call, receives both stdout and stderr.
+#           Can return CMD_FINISHED to exit early and ignore the rest of the process output.
+#           Should use an explicit  `return;` to avoid misinterpretation of return value.
 # * $input - Stdin contents for the spawned subprocess
 # * $noout - Whether to append any process output to the return value
 # * $noprint - Whether to print any process output to the parents stdout