-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_template.sh
48 lines (34 loc) · 1.07 KB
/
bash_template.sh
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
#!/usr/bin/env bash
# vim: filetype=sh
##### modeline end #####
##################################################################################################
### Inspired by Kfir Lavi - http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming ###
### Inspired by Aaron Maxwell - http://redsymbol.net/articles/unofficial-bash-strict-mode ###
##################################################################################################
set -e
set -u
set -o pipefail
IFS=$'\n\t'
readonly PROGNAME=$(basename $0)
readonly PROGDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) # OSX
#readonly PROGDIR=$(dirname $(readlink -f ${BASH_SOURCE[0]})) # Linux
readonly ARGS=("$@")
##### All vars should be local #####
##### Everything is a function #####
temporary_files() {
# Useful debug, does not work in OSX
echo $FUNCNAME $@
local dir=$1
# to debug section
set -x
ls $dir \
| grep pid \
| grep -v daemon
#finish debug section
set +x
}
main() {
local files=$(temporary_files /tmp/)
}
# Run script
main