test: Make more shell scripts verifiable by the `shellcheck` tool #23506

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:211113-lint-shell changing 2 files +5 −4
  1. hebasto commented at 6:48 PM on November 13, 2021: member

    Some shell scripts from contrib/guix and contrib/shell are not verifiable by the shellcheck tool for the following reasons:

    This PR adds these scripts to the input for the shellcheck tool, and it fixes discovered shellcheck warnings.

  2. hebasto commented at 7:07 PM on November 13, 2021: member
  3. katesalazar commented at 7:07 PM on November 13, 2021: contributor

    Concept ACK, I'd be happier adding extensions to the scripts or renaming the extension when it's a rare one (e.g. '.bash' => change to '.sh').

    The interpreter is meant to be defined in the first line of the script, not in its extension.

  4. DrahtBot added the label Scripts and tools on Nov 13, 2021
  5. DrahtBot commented at 3:10 AM on November 14, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  6. DrahtBot added the label Needs rebase on Nov 15, 2021
  7. hebasto force-pushed on Nov 15, 2021
  8. hebasto commented at 6:15 PM on November 15, 2021: member

    Rebased c6f7b89405a42248769750ed60367ae81c48d084 -> 93a7c376c78a015871285987a9ef0da518d809d4 (pr23506.01 -> pr23506.02) due to the conflict with #23462.

  9. DrahtBot removed the label Needs rebase on Nov 15, 2021
  10. dongcarl commented at 7:57 PM on November 15, 2021: member

    Concept ACK! I'm guessing shellcheck does not work with relative paths for the source= directive?

  11. hebasto commented at 9:58 PM on November 15, 2021: member

    I'm guessing shellcheck does not work with relative paths for the source= directive?

    It seems shellcheck tries to resolve them relatively to its own directory.

  12. fanquake commented at 6:32 AM on November 22, 2021: member

    Concept ACK

    and it fixes discovered shellcheck warnings.

    What warnings are being fixed here? Looks like it's just updating the source= directives?

  13. hebasto commented at 6:45 AM on November 22, 2021: member

    and it fixes discovered shellcheck warnings.

    What warnings are being fixed here? Looks like it's just updating the source= directives?

    For instance:

    $ test/lint/lint-shell.sh 
    
    In contrib/guix/guix-attest line 10:
    source "$(dirname "${BASH_SOURCE[0]}")/libexec/prelude.bash"
           ^-- SC1091: Not following: libexec/prelude.bash: openBinaryFile: does not exist (No such file or directory)
    
    For more information:
      https://www.shellcheck.net/wiki/SC1091 -- Not following: libexec/prelude.ba...
    

    I mean, "just updating the source= directives" is a fix.

  14. fanquake approved
  15. fanquake commented at 7:04 AM on November 22, 2021: member

    ACK 93a7c376c78a015871285987a9ef0da518d809d4

    I mean, "just updating the source= directives" is a fix.

    Ok. Did not test.

  16. dongcarl commented at 6:40 PM on November 22, 2021: member

    @hebasto Did you look into if it'd be possible to do relative to script path? I'm seeing on the man page that you can use a source-path directive? I'm just thinking it might make it easier if we were to rename directories in the future to not have to touch all the source= directives

  17. test: Make more shell scripts verifiable by the `shellcheck` tool a3f61676e8
  18. hebasto force-pushed on Nov 28, 2021
  19. hebasto commented at 12:30 PM on November 28, 2021: member

    Updated 93a7c376c78a015871285987a9ef0da518d809d4 -> a3f61676e83e908da67664c6163db61d1d11c5d2 (pr23506.02 -> pr23506.03, diff).

    Addressed @dongcarl's #23506 (comment):

    @hebasto Did you look into if it'd be possible to do relative to script path? I'm seeing on the man page that you can use a source-path directive? I'm just thinking it might make it easier if we were to rename directories in the future to not have to touch all the source= directives

  20. fanquake commented at 1:44 AM on November 30, 2021: member
    ./test/lint/lint-all.sh
    ....
    In contrib/guix/guix-clean line 37:
        path_residue="${2##${1}}"
                           ^--^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.
    
    Did you mean: 
        path_residue="${2##"${1}"}"
    
    For more information:
      https://www.shellcheck.net/wiki/SC2295 -- Expansions inside ${..} need to b...
    ^---- failure generated from ./test/lint/lint-shell.sh
    
  21. hebasto commented at 1:48 PM on November 30, 2021: member

    @fanquake

    ./test/lint/lint-all.sh
    ....
    In contrib/guix/guix-clean line 37:
        path_residue="${2##${1}}"
                           ^--^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.
    
    Did you mean: 
        path_residue="${2##"${1}"}"
    
    For more information:
      https://www.shellcheck.net/wiki/SC2295 -- Expansions inside ${..} need to b...
    ^---- failure generated from ./test/lint/lint-shell.sh
    

    Looks like you're using shellcheck v0.8.0, while for now https://github.com/bitcoin/bitcoin/blob/ffdf8ee43e2440ab59b85846ab98854b17e49e49/ci/lint/04_install.sh#L20

  22. hebasto commented at 1:58 PM on November 30, 2021: member

    @fanquake Please consider #23635.

  23. dongcarl commented at 5:54 PM on November 30, 2021: member

    Code Review ACK a3f61676e83e908da67664c6163db61d1d11c5d2, this is a good robustness improvement for our shell scripts.

  24. jamesob commented at 5:56 PM on November 30, 2021: member

    crACK https://github.com/bitcoin/bitcoin/pull/23506/commits/a3f61676e83e908da67664c6163db61d1d11c5d2

    Introduces shellcheck coverage, passes CI - sounds good to me.

  25. laanwj merged this on Nov 30, 2021
  26. laanwj closed this on Nov 30, 2021

  27. hebasto deleted the branch on Nov 30, 2021
  28. fanquake commented at 2:40 AM on December 1, 2021: member

    Looks like you're using shellcheck v0.8.0, while for now

    I don't understand this logic. The whole point of this PR was to start checking these scripts, and fix any issues. An issue was pointed out, and then just ignored, because it was found with a newer version of a tool. If someone found an issue in our C++ code, with a newer version of a sanitizer, we'd hardly ignore that just because we weren't using that exact version in our CI.

  29. fanquake referenced this in commit c9d7d0a653 on Dec 1, 2021
  30. sidhujag referenced this in commit c0d5e030b0 on Dec 1, 2021
  31. sidhujag referenced this in commit f566edbe76 on Dec 1, 2021
  32. hebasto commented at 8:00 AM on December 1, 2021: member

    Looks like you're using shellcheck v0.8.0, while for now

    I don't understand this logic.

    My assumption was that CI and local environments should be consistent for lint tasks. Otherwise, the local lint task could just fail with default settings. If this assumption is wrong maybe document the correct one?

    An issue was pointed out, and then just ignored, because it was found with a newer version of a tool.

    No, it was not ignored at all. To address the pointed issue, the #23635 was opened. @fanquake

    Sorry about that. I never ignored your comments before.

  33. MarcoFalke commented at 8:12 AM on December 1, 2021: member

    I think it was fine to split up the two pulls. And after all it is just the linters, so it shouldn't matter too much if it was split up or not.

  34. RandyMcMillan referenced this in commit ac65a586a9 on Dec 23, 2021
  35. RandyMcMillan referenced this in commit c3d6d3c7d1 on Dec 23, 2021
  36. dekm referenced this in commit d68e52fe4c on Oct 27, 2022
  37. DrahtBot locked this on Dec 1, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me