-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fixed.bash
More file actions
executable file
·138 lines (106 loc) · 2.99 KB
/
Copy pathtest_fixed.bash
File metadata and controls
executable file
·138 lines (106 loc) · 2.99 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/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 <<< 'for invalid-name in a b c; do echo error; done')
[ $? -eq 1 ] || err $LINENO
res=$($com <<< 'declare -n ref=XXX[0]; read -a ref <<< "A B C"')
[ $? -eq 1 ] || err $LINENO
res=$($com <<< 'for i do ii aaa ; done')
[ $? -eq 0 ] || err $LINENO
res=$($com <<< 'select a in b c d ; do echo $a ; done <<< 2')
[ "$res" = "c" ] || err $LINENO
res=$($com <<< 'for (( i = 0; i < 2; i++ )) { echo $i ; }')
[ $? -eq 0 ] || err $LINENO
[ "$res" = "0
1" ] || err $LINENO
res=$($com <<< '
a[b[c]d]=e' 2>&1 | tr -dc 0-9 )
[ "$res" = "2" ] || err $LINENO
#res=$($com <<< '
#let "rv = 7 + (43 * 6"' 2>&1 | tr -dc 0-3 )
#[ "$res" = "2" ] || err $LINENO
#
#res=$($com <<< 'declare -i i
#i=0#4' 2>&1 | tr -dc 1-3 )
#[ "$res" = "2" ] || err $LINENO
res=$($com <<< '
until (( x == 4 ))
do
echo $x
x=4
done
')
[ $? -eq 0 ] || err $LINENO
res=$($com <<< 'fuあnc() { echo aho ; }; fuあnc')
[ "$res" = "aho" ] || err $LINENO
res=$($com <<< 'fu%nc() { echo aho ; }; fu%nc')
[ "$res" = "aho" ] || err $LINENO
res=$($com <<< 'for ((i = 0; ;i++ )) ; do echo $i ; exit 0; done')
[ "$res" = "0" ] || err $LINENO
#res=$(bash <<< 'a () { echo a | rev | rev & } ; declare -f a')
#[ "$res" = 'a ()
#{
# echo a | rev | rev &
#}
#' ] || err $LINENO
if [ $(uname) = "Linux" ] ; then
res=$($com <<< '
f1()
{
local zz
zz=abcde
unset zz
zz=defghi
}
zz=ZZ
f1
echo $zz
')
[ "$res" = "ZZ" ] || err $LINENO
fi
res=$($com <<< 'cat <(exit 3) > /dev/null ; wait $!; echo $?')
[ "$res" = "3" ] || err $LINENO
res=$($com <<< 'f() { printenv A ; } ; A=333 f')
[ "$res" = "333" ] || err $LINENO
res=$($com <<< 'echo $$; moo() { ls -l "$1" ; ls -l "$1" ; }; moo >(true)')
[ $? -eq 0 ] || err $LINENO
res=$(LANG=C $com <<< 'trap 'aaaa' DEBUG
x=1' |& cat | grep "line 2:")
[ $? -eq 0 ] || err $LINENO
res=$($com <<< 'shopt -s extdebug; f() { return 2; }; trap f DEBUG; echo hoge')
[ "$res" = "" ] || err $LINENO
res=$($com <<< 'moo() { ls "$1" ; ls "$1" ; } ; moo >(true)')
[ $? -eq 0 ] || err $LINENO
res=$($com <<< '
case a in
[[:al:]) echo bad;;
*) echo ok;;
esac
')
[ "$res" = "ok" ] || err $LINENO
res=$($com <<< 'case 'a' in [[.a.]]) echo ok;; esac')
[ "$res" = "ok" ] || err $LINENO
res=$($com <<< 'case '-' in [[.hyphen.]]) echo ok;; esac')
[ "$res" = "ok" ] || err $LINENO
res=$($com <<< 'case 'p' in [[.a.]-[.z.]]) echo ok;; esac')
[ "$res" = "ok" ] || err $LINENO
res=$($com <<< 'case '-' in [[.hyphen.]-9]) echo ok;; esac')
[ "$res" = "ok" ] || err $LINENO
res=$($com <<< 'case '8' in [[.hyphen.]-9]) echo ok;; esac')
[ "$res" = "ok" ] || err $LINENO
rm -f $tmp-*
echo $0 >> ./ok
exit