blob: 588836e21ca78c415dc75cdcae3514b14694a3d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/bin/sh
set -eu
die()
{
echo "$@" 1>&2
exit 1
}
recv_hole()
{
local n
read n
truncate --size "+$n" "$1"
}
recv_data()
{
local n
read n
dd of="$1" conv=notrunc oflag=append bs=1 count="$n" status=noxfer 2>&1 |
grep -Ev ' records (in|out)$' || true
}
output="$1"
touch "$output"
while read what
do
case "$what" in
DATA) recv_data "$output" ;;
HOLE) recv_hole "$output" ;;
*) die "Unknown instruction: $what" ;;
esac
done
|