-
-
Notifications
You must be signed in to change notification settings - Fork 17.4k
versionCheckHook: Check for --version first #463218
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
versionCheckHook: Check for --version first #463218
Conversation
11a50bb to
ed0803a
Compare
|
My first thought: Does this change improve anything realistically?
Is there any evidence? 👀 |
Yeah, a quick grep shows that a 800+ packages where a bunch of us decided to manually specify this over 5 who hardcoded |
|
Hmm. If "--help" is the first default, there's no reason for people to specify "--help" explicitly. I don't think your statistic is sound. |
|
I know, I do not know why those people decided to specify that. I do know that I've been adding it to my packages as I don't see the point in calling something every time when one knows it's going to fail, both at a test build level and in Hydra. Edit: and there's also established software like ClickHouse that don't show a version number in their help usage, see: https://hydra.nixos.org/build/312909059/nixlog/2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and run research AI agents:
Gemini:
The Dominant Pattern: The GNU style of --version (exclusively for metadata) and --help (exclusively for instruction) is the overwhelming norm.
The Modern Shift: A "Hybrid" pattern is emerging, primarily in Rust-based tooling, where version info is displayed in both locations. This accounts for roughly 15-20% of newer tools but does not displace the dedicated version flag.
Gemini 2:
Based on the analysis of 108 common Linux tools, the findings are as follows:
Approximately 93% of the analyzed tools provide their version number when the --version flag (or an equivalent such as -V or -v) is used.
Approximately 53% of these tools also include their version number within the output of the --help flag (or display it when the command is invoked with invalid options or by default).
ChatGPT:
Percentage statistics: Out of our sample of 24 tools, about 25% (roughly one-quarter) included their version number in the --help output. These were mainly interactive or user-facing tools like Bash, Wget, Apt, Vim, and Nano. In contrast, almost all tools (around 95% of those sampled) provided a dedicated --version flag (or equivalent -V) to display the version info. Only very few exceptions (≈5%) lacked a version flag (for example, the minimalist shell dash).
Based on that, I am convinced this is a positive change.
|
Could you please fix the |
ed0803a to
f1d090e
Compare
|
Hmm maybe we should remove the git grep -l 'versionCheckProgramArg = "--version";' | while read f; do
sed -i '/versionCheckProgramArg/d' "$f"
done |
238c9e7 to
28e15a8
Compare
More likely to find the version number in `--version` than `--help` so look for that first.
```shell git grep -l -e 'versionCheckProgramArg = "--version";' -e 'versionCheckProgramArg = \[ "--version" \];' | while read f; do sed -i '/versionCheckProgramArg/d' "$f" sed -i '/^$/N;/\n$/D' "$f" done ```
28e15a8 to
116036d
Compare
Why didn't you use the full pattern in the sed commands? Also it seems like the last |
|
@doronbehar The last The pattern I just took from your command. |
|
Ah OK I get it now , and yes indeed I used a simpler pattern match in the |
doronbehar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, but TBH I'm not sconfident enough to merge such tree wide changes . I hope we can get a few more eyes on this.
philiptaron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read the whole thing. LGTM.
| @@ -61,7 +61,7 @@ versionCheckHook(){ | |||
| exit 2 | |||
| fi | |||
| if [[ -z "${versionCheckProgramArg}" ]]; then | |||
| for cmdArg in "--help" "--version"; do | |||
| for cmdArg in "--version" "--help"; do | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the key change.
|
Tnx!
…On 26 November 2025 18:26:12 GMT+02:00, Philip Taron ***@***.***> wrote:
Merged #463218 into staging.
--
Reply to this email directly or view it on GitHub:
#463218 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
More likely to find the version number in
--versionthan--helpso look for that first.Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.