1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # client/run.sh <function name>
|
5 |
|
6 | : ${LIB_OSH=stdlib/osh}
|
7 | source $LIB_OSH/bash-strict.sh
|
8 | source $LIB_OSH/task-five.sh
|
9 |
|
10 | source build/dev-shell.sh # python3
|
11 |
|
12 | py-demo() {
|
13 | echo mystdin | client/headless_demo.py --sh-binary bin/osh
|
14 | }
|
15 |
|
16 | cpp-demo() {
|
17 | local bin=_bin/cxx-dbg/osh
|
18 | ninja $bin
|
19 | echo mystdin | client/headless_demo.py --sh-binary $bin
|
20 | }
|
21 |
|
22 | errors() {
|
23 | set +o errexit
|
24 |
|
25 | # Invalid netstring
|
26 | client/headless_demo.py 'zzz'
|
27 | echo status=$? # TODO: assert status
|
28 |
|
29 | # Invalid command
|
30 | client/headless_demo.py '3:foo,'
|
31 | echo status=$?
|
32 |
|
33 | # Command doesn't have file descriptors
|
34 | client/headless_demo.py '4:ECMD,'
|
35 | echo status=$?
|
36 | }
|
37 |
|
38 | # Hm what is this suppose to do? It waits for input
|
39 | demo-pty() {
|
40 | echo mystdin | client/headless_demo.py --to-new-pty
|
41 | }
|
42 |
|
43 | soil-run-py() {
|
44 | py-demo
|
45 | echo
|
46 |
|
47 | errors
|
48 | echo
|
49 | }
|
50 |
|
51 | soil-run-cpp() {
|
52 | which python3
|
53 | echo
|
54 |
|
55 | cpp-demo
|
56 | }
|
57 |
|
58 |
|
59 | task-five "$@"
|