[LTP] [PATCH 2/9] metadata: parse.sh: Allow to pass list of files

Cyril Hrubis chrubis@suse.cz
Fri Feb 23 13:42:17 CET 2024


Hi!
> +if [ $# -gt 0 ]; then
> +	tests=$*
> +else
> +	tests=$(find testcases/ -name '*.c' | sort)
> +fi

This unfortunately does not work when there are unexpected characters in
the paths. Which shouldn't happen unless you pass an absoulte path to
the script which contains for example space.

I do not think that we can safely pass a list in a variable without
breaking it in that case. E.g. it works directly with $* or $@ if it's
quoted properly as:

for test in "$@"; do
	...

But as long as you pass $@ indirectly it breaks on spaces.


Note that the subshell $() with find has the same problem, but there is
much less room for breaking something because that is passed relative
paths inside of LTP.

And yes I hate argument parsing in shell..

> +for test in $tests; do
>  	a=$($top_builddir/metadata/metaparse -Iinclude -Itestcases/kernel/syscalls/utils/ "$test")
>  	if [ -n "$a" ]; then
>  		if [ -z "$first" ]; then

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list