-
Notifications
You must be signed in to change notification settings - Fork 0
/
newutl
executable file
·54 lines (50 loc) · 1.26 KB
/
newutl
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
#! /usr/bin/bash
#Brown.LiuZan@copyright
#Version: 1.1
#Date: 20190727
#Description: Used to create a utility skeletion.
#Defining section of this utility.
LZDEBUG=false
#LZDEBUG=true
#Usage checking.
if [[ $# -ne 1 ]]; then
echo -e 'Usage:\n\tnewutl.sh scriptname' >&2
echo -e 'Note:\n\tThe scriptname should end with ".sh".' >&2
exit 1
fi
if [[ ! $1 =~ .+\.sh ]]; then
echo 'The given script name should end with ".sh".' >&2
exit 1
fi
if [[ -f $1 ]]; then
echo "The $1 has already existed." >&2
exit 1
fi
touch $1
chmod a+x $1
if [[ ! -x $1 ]]; then
echo 'Failed to create and make $1 excutable.' >&2
exit 1
fi
#Make a utility skeleton.
echo '#! /usr/bin/bash' > $1
echo '################################################################################' > $1
echo '#Copyright: [email protected]' >> $1
echo '#Version: 1.0' >> $1
echo "#Date: `date +%Y-%M-%d`" >> $1
echo '#Description:' >> $1
echo '################################################################################' >> $1
echo >> $1
echo >> $1
echo '#Imports>> $1
echo 'source printer.sh' >> $1
echo >> $1
echo >> $1
echo '#Global parameters.' >> $1
echo '#LZDEBUG=false' >> $1
echo 'LZDEBUG=true' >> $1
echo >> $1
echo >> $1
echo '#Main logic.' >> $1
#Starting edit.
vim $1