Skip to content

Windows: fix pp_ctl.exe check when more than one in path - #222

Merged
esabol merged 1 commit into
bucardo:masterfrom
shawnlaffan:windows_where_call
Nov 17, 2026
Merged

esabol merged 1 commit into
bucardo:masterfrom
shawnlaffan:windows_where_call

Conversation

@shawnlaffan

Copy link
Copy Markdown
Contributor

The where call on Windows will return a multi-line string if more than one matching file is found in the path.

This will result in invalid calls in t/dbdpg_test_setup.pl, e.g.

qx{$pgctlcom}

might expand to

qx{"C:\some\path\pp_ctl.exe
C:\some\other\path\pp_ctl.exe"}

This then triggers the Found non-space whitespace in command string warning.

The where utility seems not to have an option to only return the first found so this PR simply strips everything from the first newline and/or carriage return characters.

@shawnlaffan shawnlaffan changed the title Windows: fix pp_ctl.exe check Windows: fix pp_ctl.exe check when mre than one in path Nov 16, 2026
@shawnlaffan shawnlaffan changed the title Windows: fix pp_ctl.exe check when mre than one in path Windows: fix pp_ctl.exe check when more than one in path Nov 16, 2026
Comment thread t/dbdpg_test_setup.pl Outdated
}
if ($^O =~ /Win32/) {
my $fullpath = qx{where $pg_ctl};
$fullpath =~ s/[\r\n]+?.+//; # we only want the first result

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The ? after the + seems odd and quasi-incorrect.

I suggest $fullpath =~ s/\r?\n.*//s; instead and then you can remove the chomp on the next line as it will have nothing to do. (Note: The /s modifier makes . match newlines as well, ensuring it wipes out all subsequent lines in one go.)

Before this line, I would also add:

$fullpath = '' if !defined $fullpath;

in the unlikely event the external command fails to spawn or run (for example, if the shell itself fails to launch or encounters a fatal system-level error).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

The +? is a lazy quantifier but was unnecessary here in any case.

@esabol esabol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OK, looks good. Thank you! Merging...

@esabol
esabol merged commit d06e95d into bucardo:master Nov 17, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants