From ec28f5a3f7d9c8854dcdd02f57d1f892f51cb7c0 Mon Sep 17 00:00:00 2001
From: Tristan Partin <tristan@neon.tech>
Date: Tue, 12 Dec 2023 13:22:19 -0600
Subject: [PATCH v1 4/6] Use uname -s for determining the system in
 find_typedef

Analyzing error output has proven to be unstable per a patch from Tom
after discovering we were missing some typedefs.

uname(1) is standardized by POSIX, and can be relied upon to be much
more stable.

Link: https://www.postgresql.org/message-id/flat/526703.1652385613%40sss.pgh.pa.us
---
 src/tools/find_typedef | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/tools/find_typedef b/src/tools/find_typedef
index e04c642da8..8adbe9ab94 100755
--- a/src/tools/find_typedef
+++ b/src/tools/find_typedef
@@ -31,15 +31,17 @@ then	echo "Usage:  $0 postgres_binary_directory [...]" 1>&2
 	exit 1
 fi
 
+system=$(uname -s)
+
 for DIR
-do	# if objdump -W is recognized, only one line of error should appear
-	if [ $(objdump -W 2>&1 | wc -l) -eq 1 ]
-	then	# Linux
+do
+	if [ "$system" = Linux ]
+	then
 		objdump -W "$DIR"/* |
 		grep -E -A3 '\(DW_TAG_typedef\)' |
 		awk ' $2 == "DW_AT_name" {print $NF}'
-	elif [ $(readelf -w 2>&1 | wc -l) -gt 1 ]
-	then	# FreeBSD, similar output to Linux
+	elif [ "$system" = FreeBSD ]
+	then
 		readelf -w "$DIR"/* |
 		grep -E -A3 '\(DW_TAG_typedef\)' |
 		awk ' $1 == "DW_AT_name" {print $NF}'
-- 
Tristan Partin
Neon (https://neon.tech)

