Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: remove x-prefix's from comparisons #23593

Merged

Conversation

fanquake
Copy link
Member

Very old shells suffered from bugs which meant that prefixing variables
with an "x" to ensure that the lefthand side of a comparison always
started with an alphanumeric character was needed. Modern shells don't
suffer from this issue (i.e Bash was fixed in 1996).

In any case, we've already got unprefixed checks used in our codebase, i.e

AM_CONDITIONAL([ENABLE_MAN], [test "$enable_man" != no])

and have libs (in depends) that also use unprefixed comparisons in their
configure scripts.

I think it's time that we consolidate on not using the x-prefix workaround.
At best it's mostly just confusing. Could simplify some of these checks
further in future.

More info:
https://github.com/koalaman/shellcheck/wiki/SC2268
https://www.vidarholen.net/contents/blog/?p=1035

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK.

@maflcko
Copy link
Member

maflcko commented Nov 25, 2021

Would it make sense to run one ci task with CONFIG_SHELL zsh?

@hebasto
Copy link
Member

hebasto commented Nov 25, 2021

Concept ACK.

@laanwj
Copy link
Member

laanwj commented Nov 25, 2021

Yes, seems about time. Concept ACK.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 26, 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:

  • #23675 (build: Fix build for i686-linux-android host and some small cleanups after pr23489 by hebasto)
  • #23609 (build: Enables reduced exports by default for macOS host by hebasto)
  • #22708 (build, qt: Add Wayland support for Linux builds with depends by hebasto)
  • #20201 (build: pkg-config related cleanup by hebasto)

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.

@theStack
Copy link
Contributor

Concept ACK

@laanwj
Copy link
Member

laanwj commented Nov 29, 2021

Tested successfully on FreeBSD 13.0. Would be good if someone tested on OpenBSD, NetBSD? (I might, but don't have an up-to-date install at the moment). I expect the more obscure BSDs to be the largest risk of not supporting this.

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

Tested on OpenBSD 7.0, everything works as expected.
(fresh build, configured with --without-gui --without-bdb --disable-external-signer).

@gruve-p
Copy link
Contributor

gruve-p commented Nov 30, 2021

Concept ACK

@luke-jr
Copy link
Member

luke-jr commented Nov 30, 2021

In any case, we've already got unprefixed checks used in our codebase, i.e

If it's about non-alphanumeric characters, clearly it isn't needed for yes/no values - do we have any cases where we might get passed a path?

and have libs (in depends) that also use unprefixed comparisons in their configure scripts.

Builds don't have to use depends, and presumably any platform affected would have solved this for their packages already.

That being said... we require C++17 now. If only ancient shells have this problem, seems fine.

@fanquake
Copy link
Member Author

fanquake commented Dec 1, 2021

If it's about non-alphanumeric characters, clearly it isn't needed for yes/no values

Yes, for basically all of our usage this "workaround" is pointless anyway.

do we have any cases where we might get passed a path?

I think the only case might be in some of the bdb detection logic.

Builds don't have to use depends,

Of course not. However in general, I'd guess that people building on older systems would be more likely to use depends, because it's a convenient way to get access to newer versions of our required dependencies (when system packages aren't being updated), and thus we'd have been more likely to see it reported if it was actually an issue.

@laanwj
Copy link
Member

laanwj commented Dec 2, 2021

Code review ACK 85b3656

Very old shells suffered from bugs which meant that prefixing variables
with an "x" to ensure that the lefthand side of a comparison always
started with an alphanumeric character was needed. Modern shells don't
suffer from this issue (i.e Bash was fixed in 1996).

In any case, we've already got unprefixed checks used in our codebase,
i.e https://github.com/bitcoin/bitcoin/blob/master/configure.ac#L292,
and have dependencies (in depends) that also use unprefixed comparisons.

I think it's time that we can consolidate on not using the x-prefix
workaround. At best it's mostly just confusing.

More info:
https://github.com/koalaman/shellcheck/wiki/SC2268
https://www.vidarholen.net/contents/blog/?p=1035
@fanquake fanquake force-pushed the consolidate_remove_x_prefix_var_workaround branch from 85b3656 to d6d402b Compare December 3, 2021 13:09
@maflcko
Copy link
Member

maflcko commented Dec 7, 2021

Concept ACK d6d402b

@maflcko maflcko merged commit 61b82a8 into bitcoin:master Dec 7, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 7, 2021
@jarolrod
Copy link
Member

jarolrod commented Dec 8, 2021

Post merge ACK d6d402b, tested on netbsd

RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
9a5ce04 build: remove x-prefix comparisons (fanquake)

Pull request description:

  Very old shells suffered from bugs which meant that prefixing variables
  with an "x" to ensure that the lefthand side of a comparison always
  started with an alphanumeric character was needed. Modern shells don't
  suffer from this issue (i.e Bash was fixed in 1996).

  In any case, we've already got unprefixed checks used in our codebase, i.e
  https://github.com/bitcoin/bitcoin/blob/0fc4444fc0eea0ae88ac2f87434bf2c21f5b21da/configure.ac#L292
  and have libs (in depends) that also use unprefixed comparisons in their
  configure scripts.

  I think it's time that we consolidate on not using the x-prefix workaround.
  At best it's mostly just confusing. Could simplify some of these checks
  further in future.

  More info:
  https://github.com/koalaman/shellcheck/wiki/SC2268
  https://www.vidarholen.net/contents/blog/?p=1035

ACKs for top commit:
  MarcoFalke:
    Concept ACK 9a5ce04

Tree-SHA512: 70030d61dcdb5b009823d83d73204627de53d2f628d8d6478e8e16804ac09f6bbdc53cbb1a6fb2085ebfe1a694b576e46ff381fb980cf667fab4bbadc79587d7
@fanquake fanquake deleted the consolidate_remove_x_prefix_var_workaround branch May 31, 2022 14:00
@bitcoin bitcoin locked and limited conversation to collaborators May 31, 2023
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.

10 participants