-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathskel
More file actions
executable file
·52 lines (44 loc) · 734 Bytes
/
skel
File metadata and controls
executable file
·52 lines (44 loc) · 734 Bytes
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
#!/bin/sh
# skel - create a template file in the current directory
# this file in public domain
SKEL="${SKEL:-"${XDG_DATA_HOME:-"$HOME/.local/share"}/skel"}"
usage() {
echo "usage: skel [template [name]]" >&2
exit 1
}
listskel() {
ls -1 "$SKEL"
return 0
}
createskel() {
skelfile="${SKEL}/$1"
destfile="${PWD}/$2"
if [ ! -e "$skelfile" ]
then
printf "skel: %s: skeleton file does not exist\n" "$1" >&2
exit 1
fi
if [ -e "$destfile" ]
then
printf "skel: %s: destination file already exists\n" "$2" >&2
exit 1
else
echo cp -R -- "$skelfile" "$destfile"
cp -R -- "$skelfile" "$destfile"
fi
}
case $# in
0)
listskel
;;
1)
createskel "$1" "$1"
;;
2)
createskel "$1" "$2"
;;
*)
usage
;;
esac
exit 0