[PATCH v2 03/11] scripts/carray.sh: Avoid useless use of cat

Anup Patel anup at brainfault.org
Thu Nov 28 04:33:19 PST 2024


On Tue, Nov 12, 2024 at 3:33 AM Samuel Holland
<samuel.holland at sifive.com> wrote:
>
> awk(1) takes input files as positional arguments, so there is no need
> to read the file with cat(1).
>
> Signed-off-by: Samuel Holland <samuel.holland at sifive.com>

LGTM.

Reviewed-by: Anup Patel <anup at brainfault.org>

Regards,
Anup

> ---
>
> Changes in v2:
>  - New patch for v2
>
>  scripts/carray.sh | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/carray.sh b/scripts/carray.sh
> index 72808697..16c6c136 100755
> --- a/scripts/carray.sh
> +++ b/scripts/carray.sh
> @@ -43,19 +43,19 @@ if [ ! -f "${CONFIG_FILE}" ]; then
>         usage
>  fi
>
> -TYPE_HEADER=`cat ${CONFIG_FILE} | awk '{ if ($1 == "HEADER:") { printf $2; exit 0; } }'`
> +TYPE_HEADER=$(awk '{ if ($1 == "HEADER:") { printf $2; exit 0; } }' "${CONFIG_FILE}")
>  if [ -z "${TYPE_HEADER}" ]; then
>         echo "Must specify HEADER: in input config file"
>         usage
>  fi
>
> -TYPE_NAME=`cat ${CONFIG_FILE} | awk '{ if ($1 == "TYPE:") { printf $2; for (i=3; i<=NF; i++) printf " %s", $i; exit 0; } }'`
> +TYPE_NAME=$(awk '{ if ($1 == "TYPE:") { printf $2; for (i=3; i<=NF; i++) printf " %s", $i; exit 0; } }' "${CONFIG_FILE}")
>  if [ -z "${TYPE_NAME}" ]; then
>         echo "Must specify TYPE: in input config file"
>         usage
>  fi
>
> -ARRAY_NAME=`cat ${CONFIG_FILE} | awk '{ if ($1 == "NAME:") { printf $2; exit 0; } }'`
> +ARRAY_NAME=$(awk '{ if ($1 == "NAME:") { printf $2; exit 0; } }' "${CONFIG_FILE}")
>  if [ -z "${ARRAY_NAME}" ]; then
>         echo "Must specify NAME: in input config file"
>         usage
> --
> 2.45.1
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list