From c29d17cd2d85f6ee89037377cc33821829529867 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Tue, 20 Oct 2020 17:08:31 -0400 Subject: [PATCH] port: BSD cut doesn't support '\0' as a delimiter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use a combination of 'tr' and 'head' instead which works with both the GNU and BSD version of coreutils. Change-Id: I5628863ed41030864ec08f45a3d4153c32fc5496 Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- tests/utils/utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index b33a264c2..ea354cf62 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -148,7 +148,7 @@ function lttng_pgrep () while IFS= read -r pid ; do # /proc/pid/cmdline is null separated. - if full_command_no_argument=$(cut -d '' -f 1 2>/dev/null < /proc/"$pid"/cmdline); then + if full_command_no_argument=$(tr '\0' '\n' < /proc/"$pid"/cmdline 2>/dev/null | head -n1); then command_basename=$(basename "$full_command_no_argument") if grep -q "$pattern" <<< "$command_basename"; then echo "$pid" -- 2.34.1