Skip to content

Commit 5c30f8c

Browse files
committed
nixos/test-instrumentation: fix shellcheck findings with enableStrictShellChecks enabled
Signed-off-by: Sefa Eyeoglu <[email protected]>
1 parent b792bab commit 5c30f8c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

nixos/modules/testing/test-instrumentation.nix

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,19 @@ let
1919
export HOME=/root
2020
export DISPLAY=:0.0
2121
22+
# Determine if this script is ran with nounset
23+
strict="false"
24+
if set -o | grep --quiet --perl-regexp "nounset\s+on"; then
25+
strict="true"
26+
fi
27+
2228
if [[ -e /etc/profile ]]; then
29+
# TODO: Currently shell profiles are not checked at build time,
30+
# so we need to unset stricter options to source them
31+
set +o nounset
32+
# shellcheck disable=SC1091
2333
source /etc/profile
34+
[ "$strict" = "true" ] && set -o nounset
2435
fi
2536
2637
# Don't use a pager when executing backdoor
@@ -45,7 +56,7 @@ let
4556
# we can also run non-NixOS guests during tests. This, however, is
4657
# mostly futureproofing as the test instrumentation is still very
4758
# tightly coupled to NixOS.
48-
PS1= exec ${pkgs.coreutils}/bin/env bash --norc /dev/hvc0
59+
PS1="" exec ${pkgs.coreutils}/bin/env bash --norc /dev/hvc0
4960
'';
5061
serviceConfig.KillSignal = "SIGHUP";
5162
};

0 commit comments

Comments
 (0)