From: Michael Schlenker Date: Tue, 17 Apr 2012 20:20:54 +0000 (+0200) Subject: Replace unnecessary calls to echo and cat X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/875944a23f37916a419bcf4b69e3b255ef093cde Replace unnecessary calls to echo and cat Tcl's exec can send data to stdout itself, no need to call cat/echo for that usually. --- diff --git a/tests/integration/aof.tcl b/tests/integration/aof.tcl index 9c93b6a6..ebf9cb56 100644 --- a/tests/integration/aof.tcl +++ b/tests/integration/aof.tcl @@ -35,7 +35,7 @@ tags {"aof"} { set pattern "*Unexpected end of file reading the append only file*" set retry 10 while {$retry} { - set result [exec cat [dict get $srv stdout] | tail -n1] + set result [exec tail -n1 < [dict get $srv stdout]] if {[string match $pattern $result]} { break } @@ -59,7 +59,7 @@ tags {"aof"} { set pattern "*Bad file format reading the append only file*" set retry 10 while {$retry} { - set result [exec cat [dict get $srv stdout] | tail -n1] + set result [exec tail -n1 < [dict get $srv stdout]] if {[string match $pattern $result]} { break } @@ -81,7 +81,7 @@ tags {"aof"} { } test "Short read: Utility should be able to fix the AOF" { - set result [exec echo y | src/redis-check-aof --fix $aof_path] + set result [exec src/redis-check-aof --fix $aof_path << "y\n"] assert_match "*Successfully truncated AOF*" $result } diff --git a/tests/support/server.tcl b/tests/support/server.tcl index b1ab38fc..35c1cb87 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -252,7 +252,7 @@ proc start_server {options {code undefined}} { while 1 { # check that the server actually started and is ready for connections - if {[exec cat $stdout | grep "ready to accept" | wc -l] > 0} { + if {[exec grep "ready to accept" | wc -l < $stdout] > 0} { break } after 10 diff --git a/tests/unit/aofrw.tcl b/tests/unit/aofrw.tcl index e341d77b..4716d08e 100644 --- a/tests/unit/aofrw.tcl +++ b/tests/unit/aofrw.tcl @@ -7,7 +7,7 @@ start_server {tags {"aofrw"}} { r bgrewriteaof r config set appendonly no r exec - set result [exec cat [srv 0 stdout] | tail -n1] + set result [exec tail -n1 < [srv 0 stdout] ] } {*Killing*AOF*child*} foreach d {string int} {