File 0572-snmp-test-Improved-finding-system-profiler-on-darwin.patch of Package erlang

From 55f17dd7386fcc674b6af7ead04baeae4f6c8ede Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Thu, 17 Nov 2022 19:00:41 +0100
Subject: [PATCH 2/3] [snmp|test] Improved finding system-profiler on darwin

---
 lib/snmp/test/snmp_test_lib.erl | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/lib/snmp/test/snmp_test_lib.erl b/lib/snmp/test/snmp_test_lib.erl
index 9f742c91c5..268cd6ee6d 100644
--- a/lib/snmp/test/snmp_test_lib.erl
+++ b/lib/snmp/test/snmp_test_lib.erl
@@ -2356,15 +2356,23 @@ analyze_darwin_system_profiler(DataType) ->
     %% First, make sure the program actually exist:
     case os:cmd("which system_profiler") of
         [] ->
-            [];
-        _ ->
-            D0 = os:cmd("system_profiler " ++ DataType),
-            D1 = string:tokens(D0, [$\n]),
-            D2 = [string:trim(S1) || S1 <- D1],
-            D3 = [string:tokens(S2, [$:]) || S2 <- D2],
-            analyze_darwin_system_profiler2(D3)
+            case string:trim(os:cmd("which /usr/sbin/system_profiler")) of
+                [] ->
+                    [];
+                Cmd1 ->
+                    analyze_darwin_system_profiler(Cmd1, DataType)
+            end;
+        Cmd2 ->
+            analyze_darwin_system_profiler(Cmd2, DataType)
     end.
 
+analyze_darwin_system_profiler(Cmd, DataType) ->
+    D0 = os:cmd(Cmd ++ " " ++ DataType),
+    D1 = string:tokens(D0, [$\n]),
+    D2 = [string:trim(S1) || S1 <- D1],
+    D3 = [string:tokens(S2, [$:]) || S2 <- D2],
+    analyze_darwin_system_profiler2(D3).
+
 analyze_darwin_system_profiler2(L) ->
     analyze_darwin_system_profiler2(L, []).
     
-- 
2.35.3

openSUSE Build Service is sponsored by