Thread (3 messages) 3 messages, 2 authors, 2023-01-19

Re: [PATCH V2] tools/perf/tests: Fix string substitutions in build id test

From: Athira Rajeev <hidden>
Date: 2023-01-19 14:10:07
Also in: linux-perf-users

On 19-Jan-2023, at 5:32 PM, David Laight [off-list ref] wrote:

From: Athira Rajeev
quoted
Sent: 19 January 2023 11:31
...
quoted
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

...
quoted
-	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)
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help