From 6a9a355d76c306819eb01883accf1c2f1c506d0c Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Thu, 17 Feb 2022 13:03:21 +0100 Subject: [PATCH] marsadm: fix shortcut operators --- userspace/marsadm | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/userspace/marsadm b/userspace/marsadm index a9c04209..bc19ba74 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -7537,14 +7537,23 @@ sub eval_fn { $op = "&&" if $op eq "and"; $op = "||" if $op eq "or"; my $number = parse_macro($arg1, $env); - while (defined(my $next = shift)) { - $_ = $op; - if (/^&&$/) { return 0 if !$number; } - if (/^\|\|$/) { return 1 if $number; } - my $operand = parse_macro($next, $env); - $_ = $op; - if (/^&&$/) { $number &= $operand; next; } - if (/^\|\|$/) { $number |= $operand; next; } + while (my $next_arg = shift) { + last unless defined($next_arg); + if ($op eq "&&") { + return 0 if !$number; + } + if ($op eq "||") { + return 1 if $number; + } + my $operand = parse_macro($next_arg, $env); + if ($op eq "&&") { + $number &&= $operand; + next; + } + if ($op eq "||") { + $number ||= $operand; + next; + } ldie "bad shortcut operator '$op'"; } return $number;