From 671df02bf7d0cbf339d2626266260e0b7ccf5988 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 20 Nov 2024 20:42:13 +0100 Subject: [PATCH] shellcheck --- tests/functional/flakes/non-flake-inputs.sh | 2 +- tests/functional/flakes/shebang.sh | 44 ++++++++++----------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/tests/functional/flakes/non-flake-inputs.sh b/tests/functional/flakes/non-flake-inputs.sh index 66dc74e0c..c9c9803d3 100644 --- a/tests/functional/flakes/non-flake-inputs.sh +++ b/tests/functional/flakes/non-flake-inputs.sh @@ -71,7 +71,7 @@ nix build -o "$TEST_ROOT/result" "$flake3Dir#sth" --commit-lock-file nix registry add --registry "$registry" flake3 "git+file://$flake3Dir" nix build -o "$TEST_ROOT/result" flake3#fnord -[[ $(cat $TEST_ROOT/result) = FNORD ]] +[[ $(cat "$TEST_ROOT/result") = FNORD ]] # Check whether flake input fetching is lazy: flake3#sth does not # depend on flake2, so this shouldn't fail. diff --git a/tests/functional/flakes/shebang.sh b/tests/functional/flakes/shebang.sh index 645b1fa38..576a62e2c 100644 --- a/tests/functional/flakes/shebang.sh +++ b/tests/functional/flakes/shebang.sh @@ -6,7 +6,7 @@ TODO_NixOS createFlake1 -scriptDir=$TEST_ROOT/nonFlake +scriptDir="$TEST_ROOT/nonFlake" mkdir -p "$scriptDir" cat > "$scriptDir/shebang.sh" < $scriptDir/shebang-comments.sh < "$scriptDir/shebang-comments.sh" < $scriptDir/shebang-comments.sh < $scriptDir/shebang-different-comments.sh < "$scriptDir/shebang-different-comments.sh" < $scriptDir/shebang-different-comments.sh < $scriptDir/shebang-reject.sh < "$scriptDir/shebang-reject.sh" < $scriptDir/shebang-reject.sh < $scriptDir/shebang-inline-expr.sh < "$scriptDir/shebang-inline-expr.sh" <> $scriptDir/shebang-inline-expr.sh <<"EOF" +cat >> "$scriptDir/shebang-inline-expr.sh" <<"EOF" #! nix --offline shell #! nix --impure --expr `` #! nix let flake = (builtins.getFlake (toString ../flake1)).packages; @@ -81,18 +79,18 @@ set -ex foo echo "$@" EOF -chmod +x $scriptDir/shebang-inline-expr.sh +chmod +x "$scriptDir/shebang-inline-expr.sh" -cat > $scriptDir/fooScript.nix <<"EOF" +cat > "$scriptDir/fooScript.nix" <<"EOF" let flake = (builtins.getFlake (toString ../flake1)).packages; fooScript = flake.${builtins.currentSystem}.fooScript; in fooScript EOF -cat > $scriptDir/shebang-file.sh < "$scriptDir/shebang-file.sh" <> $scriptDir/shebang-file.sh <<"EOF" +cat >> "$scriptDir/shebang-file.sh" <<"EOF" #! nix --offline shell #! nix --impure --file ./fooScript.nix #! nix --no-write-lock-file --command bash @@ -100,12 +98,12 @@ set -ex foo echo "$@" EOF -chmod +x $scriptDir/shebang-file.sh +chmod +x "$scriptDir/shebang-file.sh" -[[ $($scriptDir/shebang.sh) = "foo" ]] -[[ $($scriptDir/shebang.sh "bar") = "foo"$'\n'"bar" ]] -[[ $($scriptDir/shebang-comments.sh ) = "foo" ]] -[[ "$($scriptDir/shebang-different-comments.sh)" = "$(cat $scriptDir/shebang-different-comments.sh)" ]] -[[ $($scriptDir/shebang-inline-expr.sh baz) = "foo"$'\n'"baz" ]] -[[ $($scriptDir/shebang-file.sh baz) = "foo"$'\n'"baz" ]] -expect 1 $scriptDir/shebang-reject.sh 2>&1 | grepQuiet -F 'error: unsupported unquoted character in nix shebang: *. Use double backticks to escape?' +[[ $("$scriptDir/shebang.sh") = "foo" ]] +[[ $("$scriptDir/shebang.sh" "bar") = "foo"$'\n'"bar" ]] +[[ $("$scriptDir/shebang-comments.sh" ) = "foo" ]] +[[ "$("$scriptDir/shebang-different-comments.sh")" = "$(cat "$scriptDir/shebang-different-comments.sh")" ]] +[[ $("$scriptDir/shebang-inline-expr.sh" baz) = "foo"$'\n'"baz" ]] +[[ $("$scriptDir/shebang-file.sh" baz) = "foo"$'\n'"baz" ]] +expect 1 "$scriptDir/shebang-reject.sh" 2>&1 | grepQuiet -F 'error: unsupported unquoted character in nix shebang: *. Use double backticks to escape?'