configure.ac: remove Bashism #23557

pull whitslack wants to merge 1 commits into bitcoin:master from whitslack:fix-configure-bashism changing 1 files +1 −1
  1. whitslack commented at 7:31 PM on November 19, 2021: contributor

    Configure scripts are supposed to adhere to the POSIX shell language. The POSIX test builtin does not implement an == operator. Bash does, but not all systems have Bash installed as /bin/sh. In particular, many systems use the lighter-weight Dash as the default POSIX shell. Dash emits the following error when running configure:

    ./configure: 39065: test: xno: unexpected operator
    

    This PR removes the Bashism and restores correct operation with POSIX-compliant shells like Dash.

  2. configure.ac: remove Bashism cf7292597e
  3. hebasto commented at 7:46 PM on November 19, 2021: member

    Concept ACK.

    It seems the proper way to achieve configure script portability is to use AS_IF macro. But I'm fine with the suggested solution as well.

  4. DrahtBot added the label Build system on Nov 19, 2021
  5. MarcoFalke commented at 7:44 AM on November 20, 2021: member

    Is there a way to turn the warning into an error? We use dash in the CI, but no one is going to read the logs to find those errors.

    See https://cirrus-ci.com/task/5279449093505024?logs=ci#L1704

    Options used to compile and link:
      external signer = yes
      multiprocess    = no
      with experimental syscall sandbox support = no
      with libs       = yes
      with wallet     = yes
        with sqlite   = yes
        with bdb      = yes
      with gui / qt   = yes
        with qr       = yes
      with zmq        = yes
    ./configure: 35955: test: xno: unexpected operator
      with test       = not building test_bitcoin because fuzzing is enabled
        with fuzz     = no
    ...
    
  6. whitslack commented at 4:33 PM on November 20, 2021: contributor

    Is there a way to turn the warning into an error?

    On my Gentoo system, because this particular mistake is so common, I have a post-configure check on all builds:

    if fgrep -q -e ': unexpected operator' -e 'configure: line' "${T}/build.log" ; then
            eerror 'Package exhibits symptoms of assuming /bin/sh is Bash!'
            eerror 'Maybe setting CONFIG_SHELL=/bin/bash will work around it.'
            die
    fi
    

    It's a brittle check, but it's helped me catch and fix at least a dozen Bashisms in various packages.

  7. katesalazar commented at 11:32 AM on November 21, 2021: contributor

    ACK cf7292597e18ffca06b0fbf8bcd545aec387e380.

  8. laanwj commented at 10:20 AM on November 22, 2021: member

    Code review ACK cf7292597e18ffca06b0fbf8bcd545aec387e380

    Obvious agree that it would be good if these kind of errors were actually fatal errors.

  9. MarcoFalke merged this on Nov 22, 2021
  10. MarcoFalke closed this on Nov 22, 2021

  11. sidhujag referenced this in commit 5a35e83347 on Nov 22, 2021
  12. sidhujag referenced this in commit d088a11dfb on Nov 23, 2021
  13. whitslack deleted the branch on Jan 14, 2022
  14. DrahtBot locked this on Jan 14, 2023

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-05-01 15:14 UTC

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