Module: kamailio Branch: 5.1 Commit: b43fbb18acb86b97ff86bd867ab46c25747b2cf0 URL: https://github.com/kamailio/kamailio/commit/b43fbb18acb86b97ff86bd867ab46c25...
Author: Sebastian Kemper sebastian_ml@gmx.net Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-10-19T08:25:56+02:00
kamctl: make jsonrpc filter portable
The filter has a regex looking for a literal '{' in the beginning of a line. Some awk implementations interpret this as a meta character, so the regex is deemed broken. Example with busybox awk (POSIX):
root@hank2:~# kamctl ps awk: bad regex '^{.+"id"[ ]*:[ ]*[0-9]+[ ]*}$': Invalid contents of {} root@hank2:~#
To fix this enclose the character in square brackets. This always matches for a literal '{' and is portable.
Signed-off-by: Sebastian Kemper sebastian_ml@gmx.net (cherry picked from commit 59d287586f502a8df71c2e91899fde49594e072e)
---
Modified: utils/kamctl/kamctl.base
---
Diff: https://github.com/kamailio/kamailio/commit/b43fbb18acb86b97ff86bd867ab46c25... Patch: https://github.com/kamailio/kamailio/commit/b43fbb18acb86b97ff86bd867ab46c25...
---
diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base index 641449422c..2873c2ddb8 100644 --- a/utils/kamctl/kamctl.base +++ b/utils/kamctl/kamctl.base @@ -699,7 +699,7 @@ filter_json() $AWK 'function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s } BEGIN { line=0; IGNORECASE=1; } { line++; } - NR == 1 && /^{.+"id"[ \t]*:[ \t]*[0-9]+[ \t]*}$/ { print; next; } + NR == 1 && /^[{].+"id"[ \t]*:[ \t]*[0-9]+[ \t]*}$/ { print; next; } NR == 1 && /^200 OK/ { next; } /^[ \t]*"jsonrpc":[ \t]*"2.0"/ { print; next; } /^[ \t]*"result":[ \t]*[.+/ {