-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Get all shell scripts passing shellcheck #10795
Comments
Progress on NixOS#10795
Progress on NixOS#10795
Progress on NixOS#10795
Progress on NixOS#10795
Progress on NixOS#10795
Is there a way to run individual tests? #!/usr/bin/env bash
# this file was made by manually editing the list of the shcellcheck exluded files.
#
# Use some vim/emacs magic from the output of
#
# $ cat $_NIX_PRE_COMMIT_HOOKS_CONFIG | yq -y .repos[0].hooks[1].exclude
#
# e.g.
# tests/functional/gc.sh
# tests/functional/add.sh
# tests/functional/fmt.sh
FILES=$(cat /tmp/excluded-files.txt)
MAINT="./maintainers/flake-module.nix"
for file in $FILES
do
shellcheck -f diff "$file" | git apply
SC=$?
# if shellcheck/git patch fails.... manually fix
if [ $SC -ne 0 ]; then
echo "$file failed to be formatted manual intervention required"
nvim $file
else
# Remove the processed file from the list
#
# we need to escape the nested directories for our regex.
escaped_file=$(echo "$file" | sed -e 's/[]\/$*.^[]/\\&/g')
sed -i "/$escaped_file/d" $MAINT
# Do git stuffs
git add "$file" "$MAINT"
git commit -m "housekeeping: shellcheck for $file"
fi
done |
@SkamDart Yes there is! See https://nixos.org/manual/nix/unstable/contributing/testing and |
Got shellcheck passing for misc/systemv/nix-daemon Not sure how to test this since it's not running on my NixOS machine and I see no references to it in the directory otherwise. See NixOS#10795
What should we do about scripts like the following? nix/tests/functional/shell.shebang.sh Lines 1 to 4 in 838b666
I can't disable SC2230, or at least, I don't think I can. |
@bryanhonof we might be able to put some disables in the precommit configuration as a workaround? |
Per the discussion in #10857, on issue with shellcheck's In #10857 (comment) I through together this hackjob sed (not fully correct, just a heuristic!) that can help a big fixing. sed -i -E -e 's/( "[^"]+)"([a-z/=#_1-9-]+)( |\)|$)/\1\2"\3/' tests/functional/**.sh |
Since #10787, we are now running shellcheck on scripts.
Just like with C/C++ formatting, we are excluding almost all existing files by default. However, the reason for doing that is different than for formatting --- fixing shellcheck lint errors does not have the downside of causing merge conflicts churn, but does require manual edits. Thus we're skipping existing files not because it would be potentially bad to get them passing, but because it is more work than is appropriate for a single PR.
Scripts can one-by-one be made passing, which is a great issue to share between new contributors!
The text was updated successfully, but these errors were encountered: