[PATCH V2] tools/perf/tests: Fix string substitutions in build id test
David Laight
David.Laight at ACULAB.COM
Thu Jan 19 23:02:53 AEDT 2023
From: Athira Rajeev
> Sent: 19 January 2023 11:31
...
> diff --git a/tools/perf/tests/shell/buildid.sh b/tools/perf/tests/shell/buildid.sh
> index aaf851108ca3..43e43e131be7 100755
> --- a/tools/perf/tests/shell/buildid.sh
> +++ b/tools/perf/tests/shell/buildid.sh
> @@ -66,7 +66,7 @@ check()
> esac
> echo "build id: ${id}"
>
> - link=${build_id_dir}/.build-id/${id:0:2}/${id:2}
> + link=${build_id_dir}/.build-id/$(echo ${id}|cut -c 1-2)/$(echo ${id}|cut -c 3-)
> echo "link: ${link}"
That is horrid, why not just use valid shell substitutions, eg:
id_file=${id#??}
id_dir=${id%$id_file}
link=$build_id_dir/.build-id/$id_dir/$id_file
...
> - check ${@: -1}
> + check $last
Since this is the end of the shell function you can avoid the eval
by doing:
shift $(($# - 1))
check $1
or maybe:
args="$*"
check ${args##* }
Those should be ok in all posix shells.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
More information about the Linuxppc-dev
mailing list