From a1c5542929ffec296982d4f4034c05ed5bf4ba55 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Wed, 20 Apr 2022 13:46:54 -0700
Subject: [PATCH v10 01/16] prereq: Deal with paths containing \ and spaces in
 basebackup_to_shell tests

---
 contrib/basebackup_to_shell/t/001_basic.pl | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/contrib/basebackup_to_shell/t/001_basic.pl b/contrib/basebackup_to_shell/t/001_basic.pl
index acb66eb9a84..5eb96090a8a 100644
--- a/contrib/basebackup_to_shell/t/001_basic.pl
+++ b/contrib/basebackup_to_shell/t/001_basic.pl
@@ -16,6 +16,9 @@ if (!defined $gzip || $gzip eq '')
 	plan skip_all => 'gzip not available';
 }
 
+# to ensure path can be embedded in postgresql.conf
+$gzip =~ s{\\}{/}g if ($PostgreSQL::Test::Utils::windows_os);
+
 my $node = PostgreSQL::Test::Cluster->new('primary');
 
 # Make sure pg_hba.conf is set up to allow connections from backupuser.
@@ -53,8 +56,8 @@ $escaped_backup_path =~ s{\\}{\\\\}g
   if ($PostgreSQL::Test::Utils::windows_os);
 my $shell_command =
   $PostgreSQL::Test::Utils::windows_os
-  ? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
-  : qq{$gzip --fast > "$escaped_backup_path/%f.gz"};
+  ? qq{"$gzip" --fast > "$escaped_backup_path\\\\%f.gz"}
+  : qq{"$gzip" --fast > "$escaped_backup_path/%f.gz"};
 $node->append_conf('postgresql.conf',
 	"basebackup_to_shell.command='$shell_command'");
 $node->reload();
@@ -74,8 +77,8 @@ $node->command_fails_like(
 # Reconfigure to restrict access and require a detail.
 $shell_command =
   $PostgreSQL::Test::Utils::windows_os
-  ? qq{$gzip --fast > "$escaped_backup_path\\\\%d.%f.gz"}
-  : qq{$gzip --fast > "$escaped_backup_path/%d.%f.gz"};
+  ? qq{"$gzip" --fast > "$escaped_backup_path\\\\%d.%f.gz"}
+  : qq{"$gzip" --fast > "$escaped_backup_path/%d.%f.gz"};
 $node->append_conf('postgresql.conf',
 	"basebackup_to_shell.command='$shell_command'");
 $node->append_conf('postgresql.conf',
-- 
2.37.0.3.g30cc8d0f14

