From: Michael Jeanson Date: Tue, 20 Oct 2020 21:08:31 +0000 (-0400) Subject: port: BSD cut doesn't support '\0' as a delimiter X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c29d17cd2d85f6ee89037377cc33821829529867;p=lttng-tools.git port: BSD cut doesn't support '\0' as a delimiter 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 --- 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"