Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Nov 7, 2021

Closes #20879.
Replaces #22695.

Note for reviewers. Some touched shell scripts are not being run in CI, therefore they require more thorough reviewing:

  • contrib/devtools/gen-manpages.sh
  • contrib/macdeploy/detached-sig-apply.sh
  • contrib/windeploy/detached-sig-create.sh
  • src/qt/res/animation/makespinner.sh

@dougEfresh
Copy link
Contributor

Since you are already touching the ci scripts with double quotes "
Maybe add " around the cd P_CI_DIR in DOCKER_EXEC function:

DOCKER_CI_CMD_PREFIX bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd \"$P_CI_DIR\" && $*"

@hebasto
Copy link
Member Author

hebasto commented Nov 7, 2021

Friendly ping @dongcarl and @practicalswift
🐅

@Zero-1729
Copy link
Contributor

Approach ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 8, 2021

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #23506 (test: Make more shell scripts verifiable by the shellcheck tool by hebasto)
  • #21002 (script: improve scripted-diff check by 4D617278)
  • #19952 (build, ci: Add file-based logging for individual packages by hebasto)
  • #19013 (test: add v0.20.1, v0.21.0 and v22.0 to backwards compatibility test by Sjors)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@hebasto
Copy link
Member Author

hebasto commented Nov 8, 2021

Updated 02e9579 -> 27fbb10 (pr23462.03 -> pr23462.04):

@laanwj
Copy link
Member

laanwj commented Nov 8, 2021

Tested successfully:

  • contrib/devtools/gen-manpages.sh
  • src/qt/res/animation/makespinner.sh

Copy link
Contributor

@Zero-1729 Zero-1729 left a comment

Choose a reason for hiding this comment

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

tACK 27fbb10

Tested on macOS v12.0.1 (21A559)

Successfully tested the following files locally and can verify the SC2046 & SC2086 warnings fixed:

Note: On macOS, the default sed triggers an error when running gen-manpages.sh. This is resolved by using the GNU version gnu-sed instead (i.e. install and prepend its path in PATH to override the default sed). Running src/qt/res/animation/makespinner.sh also requires imagemagick. contrib/macdeploy/detached-sig-apply.sh requires signapple installed.

  • contrib/devtools/gen-manpages.sh
  • src/qt/res/animation/makespinner.sh
  • contrib/macdeploy/detached-sig-apply.sh

PS: the minor notes above are intended only for those who haven't run these files before on macOS.

@laanwj
Copy link
Member

laanwj commented Nov 10, 2021

Note: On macOS, the default sed triggers an error when running gen-manpages.sh.

Wrt general gen-manpages.sh frustrations: please see #22681. The sed parts are likely going to be removed completely before 0.23.


if [ "$CI_OS_NAME" == "macos" ]; then
sudo -H pip3 install --upgrade pip
# shellcheck disable=SC2086
Copy link
Member

@laanwj laanwj Nov 10, 2021

Choose a reason for hiding this comment

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

What is the idea of disabling these specific checks in some places? Is the idea that these are temporary and need to be fixed later? (but too much hassle to fix in this PR?)

Copy link
Member Author

Choose a reason for hiding this comment

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

What is the idea of disabling these specific checks in some places?

$ PIP_PACKAGES="zmq lief"
$ pip3 install --user "$PIP_PACKAGES"
ERROR: Invalid requirement: 'zmq lief'

Copy link
Member

Choose a reason for hiding this comment

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

So some code can inherently not be written to conform to SC2086?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like that. And that code requires # shellcheck disable=SC2086.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This works:

$ PIP_PACKAGES=(zmq lief)
$ pip3 install --user "${PIP_PACKAGES[@]}"

Copy link
Member

Choose a reason for hiding this comment

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

Using arrays sounds like a good idea to me. At least for scripts like this that explicitly need bash.

@dongcarl
Copy link
Contributor

Concept ACK, unintentional globbing and word splitting lead to inscrutable bugs.

We should mark with a disable= wherever we need them or simply use arrays.

@hebasto
Copy link
Member Author

hebasto commented Nov 10, 2021

Using arrays sounds like a good idea to me. At least for scripts like this that explicitly need bash.

We should mark with a disable= wherever we need them or simply use arrays.

Could we leave introducing arrays for a follow up?

@laanwj
Copy link
Member

laanwj commented Nov 10, 2021

Could we leave introducing arrays for a follow up?

Fine with me. Merging this soon closes off new such issues being introduced. And it's already the second try.

@hebasto
Copy link
Member Author

hebasto commented Nov 13, 2021

Updated 27fbb10 -> fe0ff56 (pr23462.04 -> pr23462.05):

What is the idea of disabling these specific checks in some places?

Now this PR introduces # shellcheck disable=SC2046 in two places only:

  • contrib/windeploy/detached-sig-create.sh is not a bash script, that is required to use arrays
  • in test/lint/lint-python.sh too much hassle is required to avoid it

@laanwj
Copy link
Member

laanwj commented Nov 15, 2021

Code review re-ACK fe0ff56

@laanwj laanwj merged commit aec631b into bitcoin:master Nov 15, 2021
@hebasto hebasto deleted the 211107-lintsh branch November 15, 2021 15:39
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 16, 2021
@bitcoin bitcoin locked and limited conversation to collaborators Nov 15, 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.

lint-shell: Enable SC2046 and SC2086, prevent unintentional word-splitting

7 participants