linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Yanteng Si <siyanteng@loongson.cn>, acme@kernel.org
Cc: mingo@redhat.com, peterz@infradead.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com,
	chenhuacai@kernel.org, linux-perf-users@vger.kernel.org,
	loongson-kernel@lists.loongnix.cn, loongarch@lists.linux.dev
Subject: Re: [PATCH v3 3/3] perf/trace: Use "test -f" instead of "[-f FILE]"
Date: Sat, 26 Aug 2023 17:49:29 +0800	[thread overview]
Message-ID: <ef11874aca952984d67ad5fb65b7fc1e265e2ef2.camel@xry111.site> (raw)
In-Reply-To: <b9fc1affbca15cbf18cc23905f823047b4e2f1b6.1693040967.git.siyanteng@loongson.cn>

On Sat, 2023-08-26 at 17:40 +0800, Yanteng Si wrote:
> It will be simpler without that extra subshell, so
> let's use "test -f".

Sorry for duplicated reply (I replied to v2 minutes ago), but I cannot
understand this sentence.  [ ... ] has nothing to do with subshell, it's
just a syntax variant of "test".

> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> ---
>  tools/perf/trace/beauty/mmap_flags.sh | 9 ++++++---
>  tools/perf/trace/beauty/mmap_prot.sh  | 5 +++--
>  2 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/trace/beauty/mmap_flags.sh
> b/tools/perf/trace/beauty/mmap_flags.sh
> index d035b29fc5ec..6ecdb3c5a99e 100755
> --- a/tools/perf/trace/beauty/mmap_flags.sh
> +++ b/tools/perf/trace/beauty/mmap_flags.sh
> @@ -19,7 +19,8 @@ arch_mman=${arch_header_dir}/mman.h
>  
>  printf "static const char *mmap_flags[] = {\n"
>  regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+
> )[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
> -([ -f ${arch_mman} ] && grep -E -q $regex ${arch_mman}) && \
> +test -f ${arch_mman} && \
> +grep -E -q $regex ${arch_mman} && \
>  (grep -E $regex ${arch_mman} | \
>         sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
>         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef
> MAP_%s\n#define MAP_%s %s\n#endif\n")
> @@ -28,12 +29,14 @@ grep -E -q $regex ${linux_mman} && \
>         grep -E -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
>         sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
>         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef
> MAP_%s\n#define MAP_%s %s\n#endif\n")
> -([ ! -f ${arch_mman} ] || grep -E -q
> '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*'
> ${arch_mman}) &&
> +( ! test -f ${arch_mman} || \
> +grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-
> generic/mman.*' ${arch_mman}) &&
>  (grep -E $regex ${header_dir}/mman-common.h | \
>         grep -E -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
>         sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
>         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef
> MAP_%s\n#define MAP_%s %s\n#endif\n")
> -([ ! -f ${arch_mman} ] || grep -E -q
> '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*'
> ${arch_mman}) &&
> +( ! test -f ${arch_mman} || \
> +grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-
> generic/mman.h>.*' ${arch_mman}) &&
>  (grep -E $regex ${header_dir}/mman.h | \
>         sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
>         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef
> MAP_%s\n#define MAP_%s %s\n#endif\n")
> diff --git a/tools/perf/trace/beauty/mmap_prot.sh
> b/tools/perf/trace/beauty/mmap_prot.sh
> index 49e8c865214b..4436fcd6e861 100755
> --- a/tools/perf/trace/beauty/mmap_prot.sh
> +++ b/tools/perf/trace/beauty/mmap_prot.sh
> @@ -17,12 +17,13 @@ prefix="PROT"
>  
>  printf "static const char *mmap_prot[] = {\n"
>  regex=`printf
> '^[[:space:]]*#[[:space:]]*define[[:space:]]+%s_([[:alnum:]_]+)[[:spac
> e:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' ${prefix}`
> -([ ! -f ${arch_mman} ] || grep -E -q
> '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*'
> ${arch_mman}) &&
> +( ! test -f ${arch_mman} \
> +|| grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-
> generic/mman.*' ${arch_mman}) &&
>  (grep -E $regex ${common_mman} | \
>         grep -E -vw PROT_NONE | \
>         sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \
>         xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef
> ${prefix}_%s\n#define ${prefix}_%s %s\n#endif\n")
> -[ -f ${arch_mman} ] && grep -E -q $regex ${arch_mman} &&
> +test -f ${arch_mman} && grep -E -q $regex ${arch_mman} &&
>  (grep -E $regex ${arch_mman} | \
>         grep -E -vw PROT_NONE | \
>         sed -r "s/$regex/\2 \1 \1 \1 \2/g"      | \

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2023-08-26  9:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-26  9:39 [PATCH v3 0/3] tools/perf: Add loongarch cpuinfo and fix build warning Yanteng Si
2023-08-26  9:40 ` [PATCH v3 1/3] perf/tools: Allow to use cpuinfo on LoongArch Yanteng Si
2023-08-26  9:40 ` [PATCH v3 2/3] perf/trace: Fix mmap_flags for archs use generic mman.h Yanteng Si
2023-08-26  9:40 ` [PATCH v3 3/3] perf/trace: Use "test -f" instead of "[-f FILE]" Yanteng Si
2023-08-26  9:49   ` Xi Ruoyao [this message]
2023-08-28  2:42     ` Yanteng Si

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef11874aca952984d67ad5fb65b7fc1e265e2ef2.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=chenhuacai@kernel.org \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=loongson-kernel@lists.loongnix.cn \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=siyanteng@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).