-
Notifications
You must be signed in to change notification settings - Fork 0
/
new
executable file
·119 lines (116 loc) · 3.07 KB
/
new
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
#!/bin/sh
if [ ! -f ./Makefile ]
then echo '**** must create a project first'
exit
fi
if [ -z "$1" ]
then echo '**** usage: ./new [lang] filename'
exit
fi
if [ "$1" == "c" ]
then
if [ -f $2.c ]; then echo "**** $2.c already created"; exit; fi
touch $2.c
touch $2.h
echo $2.c >> ./files.log
echo $2.h >> ./files.log
echo '//\t'$2.c >> ./$2.c
echo "//\tcreated `date`" >> ./$2.c
echo "\n\n#include \"$2.h\"" >> ./$2.c
echo '//\t'$2.h >> ./$2.h
echo "//\tcreated `date`" >> ./$2.h
echo "#ifndef __$2_H" >>./$2.h
echo "#define __$2_H" >>./$2.h
echo "#endif /* __$2_H */" >>./$2.h
sed -i.bak "s/OBJ=\(.*\)/OBJ=\1 $2.o/g" ./Makefile
rm ./Makefile.bak
echo $2.o: >> ./Makefile
echo '\t${CC} ${FLAGS} -o '$2'.o -c '$2'.c' >> ./Makefile
echo "**** Created $2.c, $2.h"
else if [ "$1" == "cpp" ]
then
if [ -f $2.cpp ]; then echo "**** $2.cpp already created"; exit; fi
touch $2.cpp
touch $2.h
echo $2.cpp >> ./files.log
echo $2.h >> ./files.log
echo '//\t'$2.cpp >> ./$2.cpp
echo "//\tcreated `date`" >> ./$2.cpp
echo "\n\n#include \"$2.h\"" >> ./$2.cpp
echo '//\t'$2.h >> ./$2.h
echo "//\tcreated `date`" >> ./$2.h
echo "#ifndef __$2_H" >>./$2.h
echo "#define __$2_H" >>./$2.h
echo "#endif /* __$2_H */" >>./$2.h
sed -i.bak "s/OBJ=\(.*\)/OBJ=\1 $2.o/g" ./Makefile
rm ./Makefile.bak
echo $2.o: >> ./Makefile
echo '\t${CC} ${FLAGS} -o '$2'.o -c '$2'.cpp' >> ./Makefile
echo "**** Created $2.cpp, $2.h"
else if [ "$1" == "h" ]
then
if [ -f $2.h ]; then echo "**** $2.cpp already created"; exit; fi
touch $2.h
echo '//\t'$2.h >> ./$2.h
echo "//\tcreated `date`" >> ./$2.h
echo "#ifndef __$2_H" >>./$2.h
echo "#define __$2_H" >>./$2.h
echo "#endif /* __$2_H */" >>./$2.h
else if [ "$1" == "java" ]
then
if [ -f $2.java ]; then echo "**** $2.java already created"; exit; fi
touch $2.java
echo $2.java >> ./files.log
echo "class $2 {" >> ./$2.java
echo "\n\n}" >> ./$2.java
sed -i.bak "s/JVC=\(.*\)/JVC=\1 $2.class/g" ./Makefile
rm ./Makefile.bak
echo $2.class: >> ./Makefile
echo '\tjavac '$2.java >> ./Makefile
echo "**** Created $2.java"
else if [ "$1" == "py" ]
then
if [ -f $2.py ]; then echo "**** $2.py already created"; exit; fi
touch $2.py
chmod 700 $2.py
echo $2.py >> ./files.log
echo "#!/usr/bin/python" >> ./$2.py
echo "**** Created $2.py"
else if [ "$1" == "pl" ]
then
if [ -f $2.pl ]; then echo "**** $2.pl already created"; exit; fi
touch $2.pl
chmod 700 $2.pl
echo $2.pl >> ./files.log
echo "#!/usr/bin/perl" >> ./$2.pl
echo "**** Created $2.pl"
else if [ "$1" == "rb" ]
then
if [ -f $2.rb ]; then echo "**** $2.rb already created"; exit; fi
touch $2.rb
chmod 700 $2.rb
echo $2.rb >> ./files.log
echo "#!/usr/bin/ruby" >> ./$2.rb
echo "**** Created $2.rb"
else if [ "$1" == "sh" ]
then
if [ -f $2.sh ]; then echo "**** $2.sh already created"; exit; fi
touch $2.sh
chmod 700 $2.sh
echo $2.sh >> ./files.log
echo "#!/bin/sh" >> ./$2.sh
echo "**** Created $2.sh"
else
if [ -f $1.txt ]; then echo "**** $1.txt already created"; exit; fi
touch $1.txt
echo $1.txt >> ./files.log
echo $1.txt >> ./$1.txt
echo "**** Created $1.txt"
fi
fi
fi
fi
fi
fi
fi
fi