Przeglądaj źródła

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 <[email protected]>
Sebastian Kemper 7 lat temu
rodzic
commit
59d287586f
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      utils/kamctl/kamctl.base

+ 1 - 1
utils/kamctl/kamctl.base

@@ -715,7 +715,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]*\[.+/ {