ci: set -u in cirrus.sh to treat unset variables as an error #1154

pull jonasnick wants to merge 2 commits into bitcoin-core:master from jonasnick:safer-cirrus-sh changing 2 files +12 −6
  1. jonasnick commented at 2:12 PM on November 16, 2022: contributor

    This PR is supposed to prevent accidental misuse of cirrus.sh. Maybe there is a way to check if CC, AR and NM are set within the loop that deals with the other variables, but so far I did not come up with one (that's POSIX shell compliant).

  2. sipa commented at 2:30 PM on November 17, 2022: contributor

    utACK 1c820cd63f00c6946435e56cc7aae312a2b2f2b6

  3. hebasto approved
  4. hebasto commented at 1:17 PM on December 16, 2022: member

    ACK 28fa827908b5f2017fd2de98d52a94d1fbaf6828, I have reviewed the code and it looks OK.

    I've compared some CI logs as well. For example, https://api.cirrus-ci.com/v1/task/5602148176625664/logs/test.log vs https://api.cirrus-ci.com/v1/task/4915160440111104/logs/test.log.

  5. in ci/cirrus.sh:35 in 28fa827908 outdated
      31 | +    if [ -n "${AR+x}" ]; then
      32 | +        echo -n "AR=\"${AR}\" "
      33 | +    fi
      34 | +    if [ -n "${NM+x}" ]; then
      35 | +        echo -n "NM=\"${NM}\" "
      36 | +    fi
    


    real-or-random commented at 3:24 PM on December 16, 2022:

    for loop and without echo -n which is not POSIX (I don't think we really care in CI but so far we tried to stick to POSIX)

        for var in CC CFLAGS AR NM; do
            eval "isset=\${$var+x}"
            if [ -n "$isset" ]; then
                eval "val=\${$var}"
                # shellcheck disable=SC2154
                printf '%s="%s" ' "$var" "$val"
            fi
        done
    

    hebasto commented at 3:37 PM on December 16, 2022:

    Can't find the point where shellcheck is called... Did I miss a script in CI?


    hebasto commented at 3:41 PM on December 16, 2022:

    With the suggested loop, why do separate CC, CFLAGS, AR and NM variables from others? A tiny overhead for a check seems an acceptable tradeoff for the succinct code, no?


    real-or-random commented at 9:48 AM on December 19, 2022:

    With the suggested loop, why do separate CC, CFLAGS, AR and NM variables from others? A tiny overhead for a check seems an acceptable tradeoff for the succinct code, no?

    Oh indeed. If we have a working loop that handles arbitrary variables, we should use it for all variables. Actually this makes me more convinced of my suggestion than I was before (the eval is somehwat ugly but having one piece of code for all env variables is probably a good idea.) @jonasnick What do you think?

    Can't find the point where shellcheck is called... Did I miss a script in CI?

    Sorry, I called it locally on my machine. :D I've seen it being very useful a few times in Core, and so I thought it doesn't hurt to add the shellcheck comment here (even if maintainers use locally). Perhaps we want to add it in the future. If @jonasnick picks up this suggestion at all, I'll let him decide if the comment is appropriate / consistent without running shellcheck in CI. ;)


    hebasto commented at 10:56 AM on December 19, 2022:

    I've seen it being very useful a few times in Core,

    Indeed.


    jonasnick commented at 1:24 PM on December 19, 2022:

    Thanks @real-or-random, with your snippet I was able to merge these variables with the loop above. I'd keep the shellcheck directive, since I'm using shellcheck locally.

  6. real-or-random commented at 3:24 PM on December 16, 2022: contributor

    ACK mod suggestion

  7. ci: set -u in cirrus.sh to treat unset variables as an error c2e0fdadeb
  8. ci: add missing CFLAGS & CPPFLAGS variable to print_environment 7a74688201
  9. jonasnick force-pushed on Dec 19, 2022
  10. real-or-random approved
  11. real-or-random commented at 1:37 PM on December 19, 2022: contributor

    ACK 7a74688201318cbbe30b0d1601aae16dc14ee17a

  12. hebasto approved
  13. hebasto commented at 1:39 PM on December 19, 2022: member

    re-ACK 7a74688201318cbbe30b0d1601aae16dc14ee17a

  14. real-or-random merged this on Dec 19, 2022
  15. real-or-random closed this on Dec 19, 2022

  16. dhruv referenced this in commit 78b5ddf28b on Jan 11, 2023
  17. dhruv referenced this in commit 215394a1d5 on Jan 11, 2023
  18. dhruv referenced this in commit 6aeec7c530 on Jan 13, 2023
  19. dhruv referenced this in commit 863cf15b37 on Jan 13, 2023
  20. dhruv referenced this in commit 61f942a096 on Jan 23, 2023
  21. dhruv referenced this in commit 4d33046ce3 on Feb 1, 2023
  22. dhruv referenced this in commit 55e7f2cf2b on Feb 2, 2023
  23. stratospher referenced this in commit 647f63669e on Feb 6, 2023
  24. dhruv referenced this in commit a4351c0df6 on Feb 20, 2023
  25. stratospher referenced this in commit 23f825fc8b on Feb 21, 2023
  26. hebasto referenced this in commit 7c0cc5d976 on Mar 7, 2023
  27. dhruv referenced this in commit a5df79db12 on Mar 7, 2023
  28. dhruv referenced this in commit 77b510d84c on Mar 7, 2023
  29. sipa referenced this in commit 763079a3f1 on Mar 8, 2023
  30. div72 referenced this in commit 945b094575 on Mar 14, 2023
  31. vmta referenced this in commit e1120c94a1 on Jun 4, 2023
  32. vmta referenced this in commit 8f03457eed on Jul 1, 2023
  33. jonasnick cross-referenced this on Jul 19, 2023 from issue Upstream PRs 1174, 1154, 1178, 1177, 1171, 1158, 1183, 1185, 1186, 1188, 1187 by jonasnick

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-18 19:15 UTC

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