[LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables

Petr Vorel pvorel@suse.cz
Fri Jun 3 20:44:34 CEST 2022


> Hi!
> > > >  	if [ -n "$TST_TEST_PATH" ]; then
> > > > -		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
> > > > +		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); do
> > >                                                                                            ^
> > > 											   Isn't
> > > 											   the
> > > 											   content
> > > 											   between
> > > 											   []
> > > 											   just
> > > 											   set?

> > > Shouldn't adding just ' between the [] suffice? The " is already there.

> > Well, '"'"' was my version of adding ' (quoted with " and ' at the start and end
> > were for ending previous '.

> > But this is shorter: '\'', therefore suggest

> > -		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
> > +		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='\''"} \t\/:`].*//'); do

> I would say that '\'' is stil insane, but I guess that we can't do
> better than that.
IMHO better than using variable:
local _tst_q="'"
for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='$_tst_q'"} \t\/:`].*//'); do

insane: well, POSIX shell is insane :).

Kind regards,
Petr


More information about the ltp mailing list