-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrun.sh
256 lines (191 loc) · 4.93 KB
/
run.sh
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#set shellc file
SHELLC="../shellc"
err()
{
if [ $? != 0 ];then
echo "ERROR: $1"
exit
fi
}
ok()
{
if [ $? != 0 ];then
echo "ERROR: $1"
else
echo "OK: $1"
fi
}
exe()
{
if [ -f ./$1.c ]; then
cc $1.c -o $1_$2.x; err "compile $1_$2.x"
#cc $1.c -Wall -o $1_$2.x; err "compile $1_$2.x"
if [ -f ./$1_$2.x ]; then
./$1_$2.x 1 2; ok "run $1_$2.x"
fi
fi
echo "Press any key to continue"
read p
rm -f $1.c $1_$2.x
clear
}
one()
{
if [ -f ./$1.c ]; then
cc $1.c -o $1_$2.x; err "compile $1_$2.x"
#cc $1.c -Wall -o $1_$2.x; err "compile $1_$2.x"
if [ -f ./$1_$2.x ]; then
./$1_$2.x ; ok "run $1_$2.x"
fi
fi
echo "Press any key to continue"
read p
rm -f $1.c $1_$2.x
clear
}
bat()
{
if [ $# != 2 ] && [ $# != 3 ];then
echo "Error sample:$@"
exit
fi
if [ $# = 2 ] || [ $# = 3 ]; then
echo "----[sample1:shellc $1 $2]----"
rm -f $2.c
$SHELLC $1 $2 ; ok "create $2.c"
exe $2 u
echo "----[sample2:shellc $1 $2 -t]----"
rm -f $2.c
$SHELLC $1 $2 -t; ok "create $2.c"
exe $2 t
echo "----[sample3:shellc $1 $2 -t -s]----"
rm -f $2.c
$SHELLC $1 $2 -t -s; ok "create $2.c"
exe $2 s
fi
if [ $# = 3 ]; then
echo "----[sample4:shellc $1 $2 -f $3]----"
rm -f $2.c
$SHELLC $1 $2 -f $3; ok "create $2.c"
exe $2 uf
echo "----[sample5:shellc $1 $2 -t -f $3]----"
rm -f $2.c
$SHELLC $1 $2 -t -f $3; ok "create $2.c"
exe $2 tf
echo "----[sample6:shellc $1 $2 -ts -f $3]----"
rm -f $2.c
$SHELLC $1 $2 -ts -f $3; ok "create $2.c"
exe $2 sf
fi
}
fix()
{
if [ $# = 3 ]; then
echo "----[fix-file1:shellc $1 $2 -e $3]----"
rm -f $2.c
$SHELLC $1 $2 -e $3; ok "create $2.c"
exe $2 ue
echo "----[fix-file2:shellc $1 $2 -t -e $3]----"
rm -f $2.c
$SHELLC $1 $2 -t -e $3; ok "create $2.c"
exe $2 te
echo "----[fix-file3:shellc $1 $2 -ts -e $3]----"
rm -f $2.c
$SHELLC $1 $2 -ts -e $3; ok "create $2.c"
exe $2 se
fi
}
run()
{
if [ $# != 2 ] && [ $# != 3 ];then
echo "Error sample:$@"
exit
fi
if [ $# = 2 ] || [ $# = 3 ]; then
echo "----[sample1:shellc $1 $2]----"
rm -f $2.c
$SHELLC $1 $2 ; ok "create $2.c"
exe $2 u
echo "----[sample2:shellc $1 $2 -t]----"
rm -f $2.c
$SHELLC $1 $2 -t; ok "create $2.c"
exe $2 t
fi
if [ $# = 3 ]; then
echo "----[sample3:shellc $1 $2 -f $3]----"
rm -f $2.c
$SHELLC $1 $2 -f $3; ok "create $2.c"
exe $2 uf
echo "----[sample4:shellc $1 $2 -t -f $3]----"
rm -f $2.c
$SHELLC $1 $2 -t -f $3; ok "create $2.c"
exe $2 tf
fi
}
inp ()
{
if [ $# != 2 ] && [ $# != 3 ];then
echo "Error sample:$@"
exit
fi
if [ $# = 2 ] ; then
echo "----[input1:shellc $1 $2 -t ]----"
rm -f $2.c
$SHELLC $1 $2 -t ; ok "create $2.c"
exe $2 fi
echo "----[input2:shellc $1 $2 -t -s ]----"
rm -f $2.c
$SHELLC $1 $2 -t -s ; ok "create $2.c"
exe $2 si
fi
if [ $# = 3 ]; then
echo "----[input1:shellc $1 $2 -t -f $3]----"
rm -f $2.c
$SHELLC $1 $2 -t -f $3; ok "create $2.c"
exe $2 fi
echo "----[input2:shellc $1 $2 -t -s -f $3]----"
rm -f $2.c
$SHELLC $1 $2 -t -s -f $3; ok "create $2.c"
exe $2 si
fi
}
clear
echo "===============run sample start==============="
bat sh test.sh
bat dash test.sh
bat bsh test.sh
#only safe mode is ok
bat Rsh test.sh
#only safe mode is ok
bat bash test.sh BASH
#fix-arg0 support bash5.0 or above
bat zsh test.sh ZSH
#Red Hat 7.8 not support fix-arg0, but using safe mode is ok
bat ksh test.sh
bat fish test.fish FISH
bat tcsh test.csh CSH
bat csh test.csh CSH
bat tclsh test.tcl TCLSH
bat fish test.fish FISH
bat perl test.pl PERL
bat lua test.lua LUA
bat python test.py PYTHON
bat python3 test.py PYTHON
bat node test.js JAVASCRIPT
bat ruby test.rb RUBY
bat php test.php PHP
#bat rc test.rc RC
fix sh test.fix fix.txt
run Rscript test.R
#The following test parameters and human-computer interaction
inp sh test_input.sh
inp fish test_input.fish FISH
inp lua test_input.lua LUA
inp perl test_input.pl PERL
inp python test_input.py PYTHON
inp python3 test_input.py PYTHON
inp node test_input.js JAVASCRIPT
inp ruby test_input.rb RUBY
inp tclsh test_input.tcl TCLSH
inp php test_input.php PHP
echo "===============run sample complete==============="