Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf beauty mmap_flags: Use "test -f" instead of "[-f FILE]"

"[" is part of the shell builtin test (and a synonym for it),
not a link to the external command /usr/bin/test.

Using the "test" is simpler because it avoids a lot of "[]".

Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
Acked-by: Huacai Chen <chenhuacai@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: loongarch@lists.linux.dev
Cc: loongson-kernel@lists.loongnix.cn
Link: https://lore.kernel.org/r/c50bc0a92dce0ff0fa6504c1a52fb53e2ac007bf.1692962043.git.siyanteng@loongson.cn
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Yanteng Si and committed by
Arnaldo Carvalho de Melo
f703073e 49cf0bf6

+9 -5
+6 -3
tools/perf/trace/beauty/mmap_flags.sh
··· 19 19 20 20 printf "static const char *mmap_flags[] = {\n" 21 21 regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' 22 - ([ -f ${arch_mman} ] && grep -E -q $regex ${arch_mman}) && \ 22 + test -f ${arch_mman} && \ 23 + grep -E -q $regex ${arch_mman} && \ 23 24 (grep -E $regex ${arch_mman} | \ 24 25 sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \ 25 26 xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n") ··· 29 28 grep -E -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \ 30 29 sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \ 31 30 xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n") 32 - ([ ! -f ${arch_mman} ] || grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) && 31 + ( ! test -f ${arch_mman} || \ 32 + grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) && 33 33 (grep -E $regex ${header_dir}/mman-common.h | \ 34 34 grep -E -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \ 35 35 sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \ 36 36 xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n") 37 - ([ ! -f ${arch_mman} ] || grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) && 37 + ( ! test -f ${arch_mman} || \ 38 + grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) && 38 39 (grep -E $regex ${header_dir}/mman.h | \ 39 40 sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \ 40 41 xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
+3 -2
tools/perf/trace/beauty/mmap_prot.sh
··· 17 17 18 18 printf "static const char *mmap_prot[] = {\n" 19 19 regex=`printf '^[[:space:]]*#[[:space:]]*define[[:space:]]+%s_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' ${prefix}` 20 - ([ ! -f ${arch_mman} ] || grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) && 20 + ( ! test -f ${arch_mman} \ 21 + || grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) && 21 22 (grep -E $regex ${common_mman} | \ 22 23 grep -E -vw PROT_NONE | \ 23 24 sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \ 24 25 xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef ${prefix}_%s\n#define ${prefix}_%s %s\n#endif\n") 25 - [ -f ${arch_mman} ] && grep -E -q $regex ${arch_mman} && 26 + test -f ${arch_mman} && grep -E -q $regex ${arch_mman} && 26 27 (grep -E $regex ${arch_mman} | \ 27 28 grep -E -vw PROT_NONE | \ 28 29 sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \