From 1bf778020ae4b700f66ea4bcdecab9720e96b4b9 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 26 Sep 2024 21:18:14 +0900 Subject: [PATCH] tools/btdecode.sh: make grep overridable This script seems to assume GNU grep, which is not commonly available as "grep" on some platforms. For examples, it's more common to have it named "ggrep" on BSD-based systems including macOS. Ideally, I suppose we should avoid GNU dependencies like this in general. But I'm not motivated enough to rewrite this script in a portable way today. cf. https://www.gnu.org/software/grep/manual/grep.html#grep-Programs-1 --- tools/btdecode.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/btdecode.sh b/tools/btdecode.sh index 964b0a3d0d..d5e04f699e 100755 --- a/tools/btdecode.sh +++ b/tools/btdecode.sh @@ -40,6 +40,8 @@ USAGE="USAGE: ${0} chip|toolchain-addr2line backtrace_file If the first argument contains 'addr2line', it will be used as the toolchain's addr2line tool. Otherwise, the script will try to identify the toolchain based on the chip name." +GREP=${GREP:-grep} + VALID_CHIPS=( "esp32" "esp32s2" @@ -119,8 +121,8 @@ while read -r line; do fi if [[ $line =~ (\[CPU[0-9]+\]\ )?sched_dumpstack: ]]; then - task_id=$(echo $line | grep -oP 'backtrace\|\s*\K\d+') - addresses=$(echo $line | grep -oP '0x[0-9a-fA-F]+') + task_id=$(echo $line | ${GREP} -oP 'backtrace\|\s*\K\d+') + addresses=$(echo $line | ${GREP} -oP '0x[0-9a-fA-F]+') if $in_dump_tasks_section; then if [[ -n "${backtraces_after[$task_id]}" ]]; then backtraces_after[$task_id]="${backtraces_after[$task_id]} $addresses" @@ -155,4 +157,4 @@ if $in_dump_tasks_section; then done echo "" done -fi \ No newline at end of file +fi