Skip to content

Commit

Permalink
port: BSD cut doesn't support '\0' as a delimiter
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jérémie Galarneau <[email protected]>
  • Loading branch information
mjeanson authored and jgalar committed Oct 31, 2022
1 parent 1524f98 commit c29d17c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/utils/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c29d17c

Please sign in to comment.