From 0635c0106946ce76c1bb84a5c17b71d0b0e574f7 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Fri, 3 Apr 2026 12:03:56 +1300
Subject: [PATCH] Harmonize tar option tests from ebba64c0.

*  GNU and BSD tar both understand --format=ustar.
*  Windows lacks /dev/null, but perl knows its local name.

Discussion: https://postgr.es/m/3676229.1775170250%40sss.pgh.pa.us
Backpatch-through: 18
---
 src/test/perl/PostgreSQL/Test/Utils.pm | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm
index 120999f6ac9..05e1698efa6 100644
--- a/src/test/perl/PostgreSQL/Test/Utils.pm
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -1328,21 +1328,14 @@ sub tar_portability_options
 
 	# GNU tar typically produces gnu-format archives, which we can read fine.
 	# But some platforms configure it to default to posix/pax format, and
-	# apparently they enable --sparse too.  Override that.
-	if (system("$tar --format=ustar -c -O /dev/null >/dev/null 2>/dev/null")
+	# apparently they enable --sparse too.  BSD tar does something similar.
+	# Override that.
+	my $devnull = File::Spec->devnull();
+	if (system("$tar --format=ustar -c $devnull >$devnull 2>$devnull")
 		== 0)
 	{
 		push(@tar_p_flags, "--format=ustar");
 	}
-
-	# bsdtar also archives sparse files by default, but it spells the switch
-	# to disable that differently.
-	if (system("$tar --no-read-sparse -c - /dev/null >/dev/null 2>/dev/null")
-		== 0)
-	{
-		push(@tar_p_flags, "--no-read-sparse");
-	}
-
 	return @tar_p_flags;
 }
 
-- 
2.53.0

