Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Nov 13, 2021

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.

@hebasto
Copy link
Member Author

hebasto commented Nov 13, 2021

cc @dongcarl

@katesalazar
Copy link
Contributor

katesalazar commented Nov 13, 2021

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 14, 2021

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

Conflicts

No conflicts as of last run.

@hebasto
Copy link
Member Author

hebasto commented Nov 15, 2021

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

@dongcarl
Copy link
Contributor

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

@hebasto
Copy link
Member Author

hebasto commented Nov 15, 2021

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.

@fanquake
Copy link
Member

Concept ACK

and it fixes discovered shellcheck warnings.

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

@hebasto
Copy link
Member Author

hebasto commented Nov 22, 2021

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.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 93a7c37

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

Ok. Did not test.

@dongcarl
Copy link
Contributor

@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

@hebasto
Copy link
Member Author

hebasto commented Nov 28, 2021

Updated 93a7c37 -> a3f6167 (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

@fanquake
Copy link
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

@hebasto
Copy link
Member Author

hebasto commented Nov 30, 2021

@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

SHELLCHECK_VERSION=v0.7.2

@hebasto
Copy link
Member Author

hebasto commented Nov 30, 2021

@fanquake Please consider #23635.

@dongcarl
Copy link
Contributor

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

@jamesob
Copy link
Contributor

jamesob commented Nov 30, 2021

crACK a3f6167

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

@laanwj laanwj merged commit c5712d1 into bitcoin:master Nov 30, 2021
@hebasto hebasto deleted the 211113-lint-shell branch November 30, 2021 19:08
@fanquake
Copy link
Member

fanquake commented Dec 1, 2021

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.

fanquake added a commit to bitcoin-core/gui that referenced this pull request Dec 1, 2021
5202bd1 test: Bump shellcheck version to 0.8.0 (Hennadii Stepanov)

Pull request description:

  Among [added](https://github.com/koalaman/shellcheck/blob/master/CHANGELOG.md#v080---2021-11-06) rules, SC2295 could be [useful](bitcoin/bitcoin#23506 (comment)) for us.

ACKs for top commit:
  dongcarl:
    Code Review ACK 5202bd1
  fanquake:
    ACK 5202bd1 - would have rather this just been a part of #23506 to avoid another PR and pointless rebasing.

Tree-SHA512: fd7ff801c71af03c5a5b2823b7daba25a430b3ead5e5e50a3663961ee2223e55d322aec91d79999814cd35bd7ed6e9415a0b797718ceb8c0b1dbdbb40c336b82
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 1, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 1, 2021
5202bd1 test: Bump shellcheck version to 0.8.0 (Hennadii Stepanov)

Pull request description:

  Among [added](https://github.com/koalaman/shellcheck/blob/master/CHANGELOG.md#v080---2021-11-06) rules, SC2295 could be [useful](bitcoin#23506 (comment)) for us.

ACKs for top commit:
  dongcarl:
    Code Review ACK 5202bd1
  fanquake:
    ACK 5202bd1 - would have rather this just been a part of bitcoin#23506 to avoid another PR and pointless rebasing.

Tree-SHA512: fd7ff801c71af03c5a5b2823b7daba25a430b3ead5e5e50a3663961ee2223e55d322aec91d79999814cd35bd7ed6e9415a0b797718ceb8c0b1dbdbb40c336b82
@hebasto
Copy link
Member Author

hebasto commented Dec 1, 2021

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.

@maflcko
Copy link
Member

maflcko commented Dec 1, 2021

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.

RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
… by the `shellcheck` tool

56a3907 test: Make more shell scripts verifiable by the `shellcheck` tool (Hennadii Stepanov)

Pull request description:

  Some shell scripts from `contrib/guix` and `contrib/shell` are not verifiable by the `shellcheck` tool for the following reasons:
  - they have no extension (see bitcoin/bitcoin@d8d1eb0 from bitcoin/bitcoin#21375)
  - they have the `.bash` extension while `.sh` is expected

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

ACKs for top commit:
  dongcarl:
    Code Review ACK 56a3907, this is a good robustness improvement for our shell scripts.
  jamesob:
    crACK bitcoin/bitcoin@56a3907

Tree-SHA512: 6703f5369d9c04c1a174491f381afa5ec2cc4d37321c1b93615abcdde4dfd3caae82868b699c25b72132d8c8c6f2e9cf24d38eb180ed4d0f0584d8c282e58935
RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
76b8372 test: Bump shellcheck version to 0.8.0 (Hennadii Stepanov)

Pull request description:

  Among [added](https://github.com/koalaman/shellcheck/blob/master/CHANGELOG.md#v080---2021-11-06) rules, SC2295 could be [useful](bitcoin/bitcoin#23506 (comment)) for us.

ACKs for top commit:
  dongcarl:
    Code Review ACK 76b8372
  fanquake:
    ACK 76b8372 - would have rather this just been a part of #23506 to avoid another PR and pointless rebasing.

Tree-SHA512: fd7ff801c71af03c5a5b2823b7daba25a430b3ead5e5e50a3663961ee2223e55d322aec91d79999814cd35bd7ed6e9415a0b797718ceb8c0b1dbdbb40c336b82
dekm pushed a commit to unigrid-project/daemon that referenced this pull request Oct 27, 2022
…`shellcheck` tool

a3f6167 test: Make more shell scripts verifiable by the `shellcheck` tool (Hennadii Stepanov)

Pull request description:

  Some shell scripts from `contrib/guix` and `contrib/shell` are not verifiable by the `shellcheck` tool for the following reasons:
  - they have no extension (see bitcoin@4eccf06 from bitcoin#21375)
  - they have the `.bash` extension while `.sh` is expected

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

ACKs for top commit:
  dongcarl:
    Code Review ACK a3f6167, this is a good robustness improvement for our shell scripts.
  jamesob:
    crACK bitcoin@a3f6167

Tree-SHA512: 6703f5369d9c04c1a174491f381afa5ec2cc4d37321c1b93615abcdde4dfd3caae82868b699c25b72132d8c8c6f2e9cf24d38eb180ed4d0f0584d8c282e58935
@bitcoin bitcoin locked and limited conversation to collaborators Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants