diff --git a/nixos/lib/test-driver/test_driver/machine.py b/nixos/lib/test-driver/test_driver/machine.py index f3e615fe5bf..ed2aceb9658 100644 --- a/nixos/lib/test-driver/test_driver/machine.py +++ b/nixos/lib/test-driver/test_driver/machine.py @@ -526,10 +526,14 @@ class Machine: self.run_callbacks() self.connect() - if timeout is not None: - command = "timeout {} sh -c {}".format(timeout, shlex.quote(command)) + # Always run command with shell opts + command = f"set -euo pipefail; {command}" + + if timeout is not None: + command = f"timeout {timeout} sh -c {shlex.quote(command)}" + + out_command = f"({command}) | (base64 --wrap 0; echo)\n" - out_command = f"( set -euo pipefail; {command} ) | (base64 --wrap 0; echo)\n" assert self.shell self.shell.send(out_command.encode())