-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fixed.bash
More file actions
executable file
·70 lines (52 loc) · 1.52 KB
/
test_fixed.bash
File metadata and controls
executable file
·70 lines (52 loc) · 1.52 KB
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
61
62
63
64
65
66
67
68
69
#!/bin/bash -xv
# SPDX-FileCopyrightText: 2025 Ryuichi Ueda ryuichiueda@gmail.com
# SPDX-License-Identifier: GPL-3.0-or-later
err () {
echo $0 >> ./error
echo "ERROR!" FILE: $0, LINENO: $1
rm -f $tmp-*
exit 1
}
repo_dir=${2:-~/GIT/rusty_bash}
test_dir="$PWD"
com="$repo_dir/target/debug/sush"
cd "$repo_dir"
tmp=/tmp/$$
[ "$1" == "nobuild" ] || cargo build || err $LINENO
cd "$test_dir"
res=$($com <<< 'echo " a b\ " | ( read x y ; echo -"$x"-"$y"- )')
[ "$res" = "-a-b -" ] || err $LINENO
res=$($com <<< 'echo " a b\ " | ( read x ; echo -"$x"- )')
[ "$res" = "-a b-" ] || err $LINENO
res=$($com <<< 'echo "a b " | ( read x y z ; echo ${z-z not set} 2>&1 )')
[ "$res" = "" ] || err $LINENO
res=$($com <<< 'echo "A B " | ( read ; echo "[$REPLY]" )')
[ "$res" = "[A B ]" ] || err $LINENO
res=$($com <<< 'echo " A B " | ( read ; echo "[$REPLY]" )')
[ "$res" = "[ A B ]" ] || err $LINENO
res=$($com <<< '(sleep 2 ; echo aaa) | read -t 1 a ; echo $a')
[ "$res" = "" ] || err $LINENO
res=$($com <<< '(sleep 2 ; echo aaa) | read -t 1 a')
[ $? -gt 128 ] || err $LINENO
res=$($com <<< 'echo ${A:aaa} ${A:"aaa"}')
[ $? -eq 0 ] || err $LINENO
res=$($com << 'EOF'
echo ${A:'aaa'}
EOF
)
[ $? -eq 0 ] || err $LINENO
res=$($com <<< 'A= ; echo ${A:aaa} ${A:"aaa"}')
[ $? -eq 0 ] || err $LINENO
res=$($com << 'EOF'
A=
echo ${A:'aaa'}
EOF
)
[ $? -eq 1 ] || err $LINENO
res=$($com <<< 'A=abc; echo ${A:13:23:3aa}')
[ $? -eq 0 ] || err $LINENO
res=$($com <<< 'A=abc; echo ${A:1:23:3aa}')
[ $? -eq 1 ] || err $LINENO
rm -f $tmp-*
echo $0 >> ./ok
exit