Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/test-instrumentation: fix shellcheck findings with enableStrictShellChecks enabled #349579

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion nixos/modules/testing/test-instrumentation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ let
export HOME=/root
export DISPLAY=:0.0

# Determine if this script is ran with nounset
strict="false"
if set -o | grep --quiet --perl-regexp "nounset\s+on"; then
strict="true"
fi

if [[ -e /etc/profile ]]; then
# TODO: Currently shell profiles are not checked at build time,
# so we need to unset stricter options to source them
set +o nounset
# shellcheck disable=SC1091
source /etc/profile
[ "$strict" = "true" ] && set -o nounset
fi

# Don't use a pager when executing backdoor
Expand All @@ -45,7 +56,7 @@ let
# we can also run non-NixOS guests during tests. This, however, is
# mostly futureproofing as the test instrumentation is still very
# tightly coupled to NixOS.
PS1= exec ${pkgs.coreutils}/bin/env bash --norc /dev/hvc0
PS1="" exec ${pkgs.coreutils}/bin/env bash --norc /dev/hvc0
'';
serviceConfig.KillSignal = "SIGHUP";
};
Expand Down