[PATCH V2] tools/perf/tests: Fix string substitutions in build id test
Athira Rajeev
atrajeev at linux.vnet.ibm.com
Fri Jan 20 01:08:40 AEDT 2023
> On 19-Jan-2023, at 5:32 PM, David Laight <David.Laight at ACULAB.COM> wrote:
>
> 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
>
Hi David,
Thanks for the review. I will post a V3 addressing these changes.
Athira
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
More information about the Linuxppc-dev
mailing list