I need to create a set of regex patterns to be used within the --remove
option of the lcov
command, in order to remove some pointless entries in the coverage file.
Reading the manpage of lcov
it seems the list of patterns shall be handed to it as a space-separated single-quoted strings (as in 'patte*n1' 'pa*ter*2' 'p*3'
and so on).
I was able to write a small bash script which generates exactly the list I need, in the form required by the command. If I issue
export LIST=$( ./myscript.sh )
and then, do a echo $LIST
, I get the list I expect to
'path/file1' 'path/file2' 'path/file3'
(the regex patterns list is comprised of the ending part of some patterns to be removed from the analysis).
The problem arises when I pass this list to the command:
lcov --remove coverage_report.info '/usr/*' $( echo $LIST ) --output-file coverage_report.info.cleaned
in order to remove both /usr/* and the files from my list, but it does not work as expected: no path from my path list is actually removed. I tried different forms of it:
echo $LIST | xargs -i lcov --remove coverage_report.info {} --output-file coverage_report.info.cleaned
If I take the output of echo $LIST
and copy/paste it directly on the command line, the command actually works and removes all the path I'd like to get rid of. My impression is that I'm not aware of all inner aspects of some commands' options processing and the order of evaluation of nested commands.
Thanks in advance to any people willing to help!