-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_essentials.sh
More file actions
40 lines (35 loc) · 809 Bytes
/
bash_essentials.sh
File metadata and controls
40 lines (35 loc) · 809 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
# useful batch functions and scripts for use in a vareity of programs
# confirm function, takes y/n
confirm () {
read -r -p "${1:-Are you sure? [y/N]} " response </dev/tty
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
# catches Ctrl+C and other kill commands
function cleanup {
exit
}
trap cleanup SIGHUP SIGINT SIGKILL SIGTERM SIGSTOP
# option input for generic program
for i in "$@"; do
case $i in
-t=*|--title=*)
title="${i#*=}"
shift # past argument=value
;;
-y=*|--year=*)
year="${i#*=}"
shift # past argument=value
;;
-e=*|--extension=*)
extension="${i#*=}"
shift # past argument=value
;;
esac
done