[LTP] test.sh and ROD redirection

Cyril Hrubis chrubis@suse.cz
Mon Jan 25 18:18:27 CET 2016


Hi!
> > +			flag=1
> > +			continue
> May be break here, so we don't need the next if block.

We have to do another loop just to fetch the parameter after the \> if
there is space between \> and path. So the continue should stay.

Full version then would be:

--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -214,7 +214,35 @@ ROD_SILENT()
 
 ROD()
 {
-       $@
+       local cmd
+       local arg
+       local file
+       local flag
+
+       for arg; do
+               file="${arg#\>}"
+               if [ "$file" != "$arg" ]; then
+                       if [ -n "$file" ]; then
+                               break
+                       fi
+                       flag=1
+                       continue
+               fi
+
+               if [ -n "$flag" ]; then
+                       file="$arg"
+                       break
+               fi
+
+               cmd="$cmd $arg"
+       done
+
+       if [ -n "$file" ]; then
+               $cmd > $file
+       else
+               $@
+       fi
+
        if [ $? -ne 0 ]; then
                tst_brkm TBROK "$@ failed"
        fi



This works both with:

ROD echo a \> file
ROD echo a \>file


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the Ltp mailing list