port: BSD cut doesn't support '\0' as a delimiter
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 20 Oct 2020 21:08:31 +0000 (17:08 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 31 Oct 2022 18:00:56 +0000 (14:00 -0400)
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 <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/utils.sh

index b33a264c2597fd4ca06b6fa08fcf3872ec9a897f..ea354cf62fc4236f4201e834e0353d0317eb1210 100644 (file)
@@ -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"
This page took 0.02533 seconds and 4 git commands to generate.