diff: omit found pointer from emit_callback
[gitweb.git] / t / test-lib-functions.sh
index ca40a1289f269830e30136459a09fc2526957895..4f7eadb5963e7d698f9ee6e265b1657e543cdb44 100644 (file)
@@ -976,3 +976,17 @@ test_match_signal () {
        fi
        return 1
 }
+
+# Read up to "$1" bytes (or to EOF) from stdin and write them to stdout.
+test_copy_bytes () {
+       perl -e '
+               my $len = $ARGV[1];
+               while ($len > 0) {
+                       my $s;
+                       my $nread = sysread(STDIN, $s, $len);
+                       die "cannot read: $!" unless defined($nread);
+                       print $s;
+                       $len -= $nread;
+               }
+       ' - "$1"
+}