-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·60 lines (49 loc) · 896 Bytes
/
run
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
#!/usr/bin/env bash
clear
file=$1
browser=firefox
if [[ $file =~ .+\.c$ ]]; then
#echo C file
out=${file/%.c}.out
#echo $out
gcc -o $out $file -lm
if [ $? -eq 0 ]; then
if [[ ${out:0:1} = / ]]; then
$out
else
./$out
fi
fi
elif [[ $file =~ .+\.cpp$ ]]; then
#echo C++ file
out=${file/%.cpp}.out
#echo $out
g++ -o $out $file
if [ $? -eq 0 ]; then
if [[ ${out:0:1} = / ]]; then
$out
else
./$out
fi
fi
elif [[ $file =~ .+\.java ]]; then
javac $file
if [ $? -eq 0 ]; then
java ${file/%.java}
fi
elif [[ $file =~ .+\.py$ ]]; then
#echo Python file
python $file
elif [[ $file =~ .+\.pl$ ]]; then
#echo Perl file
perl $file
elif [[ $file =~ .+\.tex$ ]]; then
pdflatex $file
if [ $? -eq 0 ]; then
qpdfview ${file/%.tex}.pdf &
fi
elif [[ $file =~ .+\.html$ ]]; then
$browser $file
else
echo "Not a C/C++/Python/Perl/LaTex/HTML source file"
fi