perf beauty socket/prctl_option: Cope with extended regexp complaint by grep
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 6 Oct 2023 19:14:54 +0000 (16:14 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 31 Oct 2023 15:31:19 +0000 (12:31 -0300)
Noticed on fedora 38, the extended regexp that so far was ok for both
grep and sed now gets complaints by grep, that says '/' doesn't need to
be escaped with '\'.

So stop using '/' in sed, use '%' instead and remove the \ before / in
the common extended regexp.

Link: https://x.com/SMT_Solvers/status/1710380010098344192?s=20
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/ZUEddFPTJHVLhH%2F6@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/trace/beauty/prctl_option.sh
tools/perf/trace/beauty/socket.sh

index 8059342ca4126c381a144073f169cba6bc46a059..9455d9672f140d13daa1502bf5faf3c7986a8cc5 100755 (executable)
@@ -4,9 +4,9 @@
 [ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
 
 printf "static const char *prctl_options[] = {\n"
-regex='^#define[[:space:]]{1}PR_(\w+)[[:space:]]*([[:xdigit:]]+)([[:space:]]*\/.*)?$'
+regex='^#define[[:space:]]{1}PR_(\w+)[[:space:]]*([[:xdigit:]]+)([[:space:]]*/.*)?$'
 grep -E $regex ${header_dir}/prctl.h | grep -v PR_SET_PTRACER | \
-       sed -r "s/$regex/\2 \1/g"       | \
+       sed -E "s%$regex%\2 \1%g"       | \
        sort -n | xargs printf "\t[%s] = \"%s\",\n"
 printf "};\n"
 
index 8bc7ba62203e4a9d3c327487027d05d4da5a21fe..670c6db298ae029812a5eaa885cb986e7a1f56b2 100755 (executable)
@@ -18,10 +18,10 @@ grep -E $ipproto_regex ${uapi_header_dir}/in.h | \
 printf "};\n\n"
 
 printf "static const char *socket_level[] = {\n"
-socket_level_regex='^#define[[:space:]]+SOL_(\w+)[[:space:]]+([[:digit:]]+)([[:space:]]+\/.*)?'
+socket_level_regex='^#define[[:space:]]+SOL_(\w+)[[:space:]]+([[:digit:]]+)([[:space:]]+/.*)?'
 
 grep -E $socket_level_regex ${beauty_header_dir}/socket.h | \
-       sed -r "s/$socket_level_regex/\2 \1/g"  | \
+       sed -E "s%$socket_level_regex%\2 \1%g"  | \
        sort -n | xargs printf "\t[%s] = \"%s\",\n"
 printf "};\n\n"