[LTP] [PATCH] network/nfs_lib.sh: Use double quotes for grep pattern

Petr Vorel pvorel@suse.cz
Wed Jun 17 20:43:56 CEST 2020


Hi Alexey, Xiao,

> Perhaps this:

> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
> index 59b373e..9c8f163 100644
> --- a/testcases/lib/tst_net.sh
> +++ b/testcases/lib/tst_net.sh
> @@ -172,8 +172,7 @@ tst_rhost_run()
>         local output=
>         local ret=0
>         if [ -n "${TST_USE_SSH:-}" ]; then
> -               output=`ssh -n -q $user@$RHOST "sh -c \
> -                       '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'`
> +               output=$(ssh -n -q $user@$RHOST "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR')
>         elif [ -n "$TST_USE_NETNS" ]; then
>                 output=`$LTP_NETNS sh -c \
>                         "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR'`

Nice! Much simpler than what what I was just going to post (sed replacement).
Would it work for rsh as well? i.e. can it work without sh -c?
I have no working rsh setup.

And removing it from all 3 variants would be great (keeping them to be the same,
also it might allow to also use shell functions, which doesn't work with sh -c
"..."). Why was sh -c "..." used anyway?

BTW I have more tst_net.sh, but I post them after we solve this one (as
replacing quotes with sed, which is in my prepared patchset is ugly).

Kind regards,
Petr


More information about the ltp mailing list