generic/014: Fix wrong return value in output
authorZhao Lei <zhaolei@cn.fujitsu.com>
Tue, 22 Sep 2015 00:45:20 +0000 (10:45 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 22 Sep 2015 00:45:20 +0000 (10:45 +1000)
Current code always output "truncfile returned 0" because $? was
modified by previous command. Use $ret to indicate the correct
return value from truncfile.

[dchinner: fix formatting issues, update commit message.]

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
tests/generic/014

index 79619619eb7f73ca3134c1693536787c51a7558a..a144a4740d16efb7b12ae8d7b0b972124d26455b 100755 (executable)
@@ -61,12 +61,13 @@ echo "brevity is wit..."
 echo "------"
 echo "test 1"
 echo "------"
-if ! src/truncfile -c 10000 $TEST_DIR/truncfile.$$.0 >$tmp.out 2>&1
-then
-    out=`cat $tmp.out`
-    echo "truncfile returned $? : \"$out\""
+src/truncfile -c 10000 $TEST_DIR/truncfile.$$.0 >$tmp.out 2>&1
+ret=$?
+if [ "$ret" -ne 0 ]; then
+       out=`cat $tmp.out`
+       echo "truncfile returned $ret : \"$out\""
 else
-    echo "OK"
+       echo "OK"
 fi
 
 exit