1 |
#### sh -c |
2 |
$SH -c 'echo hi' |
3 |
## stdout: hi |
4 |
## status: 0 |
5 |
|
6 |
#### empty -c input |
7 |
# had a bug here |
8 |
$SH -c '' |
9 |
## stdout-json: "" |
10 |
## status: 0 |
11 |
|
12 |
#### sh +c is accepted |
13 |
$SH +c 'echo hi' |
14 |
## stdout: hi |
15 |
## status: 0 |
16 |
## N-I mksh/yash stdout-json: "" |
17 |
## N-I mksh/yash status: 127 |
18 |
|
19 |
#### empty stdin |
20 |
# had a bug here |
21 |
echo -n '' | $SH |
22 |
## stdout-json: "" |
23 |
## status: 0 |
24 |
|
25 |
#### shell obeys --help (regression for OSH) |
26 |
n=$($SH --help | wc -l) |
27 |
if test $n -gt 0; then |
28 |
echo yes |
29 |
fi |
30 |
## STDOUT: |
31 |
yes |
32 |
## END |
33 |
## N-I dash/mksh stdout-json: "" |
34 |
|
35 |
#### args are passed |
36 |
$SH -c 'argv.py "$@"' dummy a b |
37 |
## stdout: ['a', 'b'] |
38 |
|
39 |
#### args that look like flags are passed after script |
40 |
script=$TMP/sh1.sh |
41 |
echo 'argv.py "$@"' > $script |
42 |
chmod +x $script |
43 |
$SH $script --help --help -h |
44 |
## stdout: ['--help', '--help', '-h'] |
45 |
|
46 |
#### args that look like flags are passed after -c |
47 |
$SH -c 'argv.py "$@"' --help --help -h |
48 |
## stdout: ['--help', '-h'] |
49 |
|
50 |
#### exit with explicit arg |
51 |
exit 42 |
52 |
## status: 42 |
53 |
|
54 |
#### exit with no args |
55 |
false |
56 |
exit |
57 |
## status: 1 |
58 |
|
59 |
#### --rcfile in non-interactive shell prints warnings |
60 |
echo 'echo rc' > rc |
61 |
|
62 |
$SH --rcfile rc -i </dev/null 2>interactive.txt |
63 |
grep -q 'warning' interactive.txt |
64 |
echo warned=$? >&2 |
65 |
|
66 |
$SH --rcfile rc </dev/null 2>non-interactive.txt |
67 |
grep -q 'warning' non-interactive.txt |
68 |
echo warned=$? >&2 |
69 |
|
70 |
head *interactive.txt |
71 |
|
72 |
## STDERR: |
73 |
warned=1 |
74 |
warned=0 |
75 |
## END |
76 |
## N-I bash/dash/mksh/zsh STDERR: |
77 |
warned=1 |
78 |
warned=1 |
79 |
## END |
80 |
|
81 |
#### accepts -l flag |
82 |
$SH -l -c 'exit 0' |
83 |
## status: 0 |
84 |
|
85 |
|
86 |
#### accepts --login flag (dash and mksh don't accept long flags) |
87 |
$SH --login -c 'exit 0' |
88 |
## status: 0 |
89 |
## OK dash status: 2 |
90 |
## OK mksh status: 1 |