Skip to content

Commit ed0803a

Browse files
committed
versionCheckHook: Check for --version first
More likely to find the version number in `--version` than `--help` so look for that first.
1 parent d0291e3 commit ed0803a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

doc/hooks/versionCheckHook.section.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The variables that this phase control are:
3030

3131
- `dontVersionCheck`: Disable adding this hook to the [`preInstallCheckHooks`](#ssec-installCheck-phase). Useful if you do want to load the bash functions of the hook, but run them differently.
3232
- `versionCheckProgram`: The full path to the program that should print the `${version}` string. Defaults to using the first non-empty value `$binary` out of `${NIX_MAIN_PROGRAM}` and `${pname}`, in that order, to build roughly `${placeholder "out"}/bin/$binary`. `${NIX_MAIN_PROGRAM}`'s value comes from `meta.mainProgram`, and does not normally need to be set explicitly. When setting `versionCheckProgram`, using `$out` directly won't work, as environment variables from this variable are not expanded by the hook. Hence using `placeholder "out"` is unavoidable.
33-
- `versionCheckProgramArg`: The argument that needs to be passed to `versionCheckProgram`. If undefined the hook tries first `--help` and then `--version`. Examples: `version`, `-V`, `-v`.
33+
- `versionCheckProgramArg`: The argument that needs to be passed to `versionCheckProgram`. If undefined the hook tries first `--version` and then `--help`. Examples: `version`, `-V`, `-v`.
3434
- `versionCheckKeepEnvironment`: A list of environment variables to keep and pass to the command. Only those variables should be added to this list that are actually required for the version command to work. If it is not feasible to explicitly list all these environment variables you can set this parameter to the special value `"*"` to disable the `--ignore-environment` flag and thus keep all environment variables.
3535
- `preVersionCheck`: A hook to run before the check is done.
3636
- `postVersionCheck`: A hook to run after the check is done.

pkgs/by-name/ve/versionCheckHook/hook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ versionCheckHook(){
6161
exit 2
6262
fi
6363
if [[ -z "${versionCheckProgramArg}" ]]; then
64-
for cmdArg in "--help" "--version"; do
64+
for cmdArg in "--version" "--help"; do
6565
echoPrefix="$(_handleCmdOutput "$cmdProgram" "$cmdArg" "$versionCheckKeepEnvironment")"
6666
if [[ "$echoPrefix" == "Successfully managed to" ]]; then
6767
break

0 commit comments

Comments
 (0)