From c0731a5e33bd0e5aef27ec5bfdba5cf8ba98b726 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 24 Jun 2026 11:21:59 -0300 Subject: [PATCH] fix(xcat-test): run testcase commands under bash, not /bin/sh xcattest's runcmd ran each RUN: command via Perl backticks, i.e. /bin/sh. On Ubuntu /bin/sh is dash, so testcases using bashisms ([ x == y ], [[ ... ]]) error with "unexpected operator": the [ exits non-zero, the enclosing if is taken as false, and the case's distro-specific branch is silently skipped while the case still reports Passed -- a false pass. Run the command through bash via list-form open() so no intervening /bin/sh re-parses or re-expands the command's embedded quotes and backticks. EL is unaffected (its /bin/sh is already bash). Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/xcattest | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index 708ae79ca..bc89b4532 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -1683,7 +1683,13 @@ sub runcmd my $rc = 0; $::RUNCMD_RC = 0; my $outref = []; - @$outref = `$cmd 2>&1`; + # xCAT-test cases use bashisms ([ x == y ], [[ ]]); on Ubuntu /bin/sh is dash, so run + # the command under bash. open('-|', LIST) execs bash directly -- no intervening + # /bin/sh, so the cases' embedded quotes/backticks are not re-parsed or re-expanded. + if (open(my $cfh, '-|', '/bin/bash', '-c', "$cmd 2>&1")) { + @$outref = <$cfh>; + close($cfh); # sets $? just like the backtick did + } if ($?) { $rc = $?;