aboutsummaryrefslogtreecommitdiff
path: root/paludis/util/system_TEST_setup.sh
blob: 5bdc42a4748f13e463140849892ff87d90dd3abb (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
# vim: set ft=sh sw=4 sts=4 et :

mkdir system_TEST_dir || exit 2
cd system_TEST_dir || exit 3

cat <<'END' > pipe_test.bash
#!/usr/bin/env bash

echo "$1" | tr "\n" "\0" 1>&$PALUDIS_PIPE_COMMAND_WRITE_FD
response1=
while true ; do
    c=$(head -c1 <&$PALUDIS_PIPE_COMMAND_READ_FD )
    [[ "$c" == $'\0' ]] && break
    response1="${response1}${c}"
done

echo "$2" | tr "\n" "\0" 1>&$PALUDIS_PIPE_COMMAND_WRITE_FD
response2=
while true ; do
    c=$(head -c1 <&$PALUDIS_PIPE_COMMAND_READ_FD )
    [[ "$c" == $'\0' ]] && break
    response2="${response2}${c}"
done

exit $response1$response2
END

cat <<'END' > captured_pipe_test.bash
#!/usr/bin/env bash

echo "$1" | tr "\n" "\0" 1>&$PALUDIS_PIPE_COMMAND_WRITE_FD
response1=
while true ; do
    c=$(head -c1 <&$PALUDIS_PIPE_COMMAND_READ_FD )
    [[ "$c" == $'\0' ]] && break
    response1="${response1}${c}"
done

echo "$2" | tr "\n" "\0" 1>&$PALUDIS_PIPE_COMMAND_WRITE_FD
response2=
while true ; do
    c=$(head -c1 <&$PALUDIS_PIPE_COMMAND_READ_FD )
    [[ "$c" == $'\0' ]] && break
    response2="${response2}${c}"
done

echo "$3" | tr "\n" "\0" 1>&$PALUDIS_PIPE_COMMAND_WRITE_FD
response3=
while true ; do
    c=$(head -c1 <&$PALUDIS_PIPE_COMMAND_READ_FD )
    [[ "$c" == $'\0' ]] && break
    response3="${response3}${c}"
done

echo $response2

exit $response1$response3
END