1 |
#!/bin/bash |
2 |
# |
3 |
# Usage: |
4 |
# ./sh-usage.test.sh <function name> |
5 |
|
6 |
#### sh -c |
7 |
$SH -c 'echo hi' |
8 |
## stdout: hi |
9 |
## status: 0 |
10 |
|
11 |
#### empty -c input |
12 |
# had a bug here |
13 |
$SH -c '' |
14 |
## stdout-json: "" |
15 |
## status: 0 |
16 |
|
17 |
#### empty stdin |
18 |
# had a bug here |
19 |
echo -n '' | $SH |
20 |
## stdout-json: "" |
21 |
## status: 0 |
22 |
|
23 |
#### args are passed |
24 |
$SH -c 'argv.py "$@"' dummy a b |
25 |
## stdout: ['a', 'b'] |
26 |
|
27 |
#### args that look like flags are passed after script |
28 |
script=$TMP/sh1.sh |
29 |
echo 'argv.py "$@"' > $script |
30 |
chmod +x $script |
31 |
$SH $script --help --help -h |
32 |
## stdout: ['--help', '--help', '-h'] |
33 |
|
34 |
#### args that look like flags are passed after -c |
35 |
$SH -c 'argv.py "$@"' --help --help -h |
36 |
## stdout: ['--help', '-h'] |
37 |
|
38 |
#### exit with explicit arg |
39 |
exit 42 |
40 |
## status: 42 |
41 |
|
42 |
#### exit with no args |
43 |
false |
44 |
exit |
45 |
## status: 1 |