forked from OKEAMAH/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell-utils
More file actions
52 lines (38 loc) · 1.05 KB
/
shell-utils
File metadata and controls
52 lines (38 loc) · 1.05 KB
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
# -*- shell -*-
# ----------------------------------------------------------------------
# Helpers
#
[ "$program" ] || program=${0##*/}
function die() {
echo "$program: Error: $*" 1>&2;
exit 2
}
function err() {
echo "$program: Error: $*" 1>&2;
exit 2
}
function warn() {
echo "$program: Warning: $*" 1>&2;
warnings=1
}
function note() {
if [ -n "$OPT_VERBOSE" ]; then say $*; fi
}
function say() {
echo -e "$program: $*" 1>&2;
}
function version() {
echo -e "$program: v$version\n\nRunning as $(id -urn) on $(date +'%Y-%m-%d %H:%M')"
}
function filedate() {
ls --full-time "$1" | tr ":." " " | awk '{printf "%sT%s:%s:%s%s:%s\n", $6, $7, $8, $9, substr($11,1,3), substr($11,4,2)}';
}
function py_module_path() {
module=$1
python -c "import $module, os.path; print os.path.realpath($module.__path__[0])"
}
function py_module_file() {
module=$1
python -c "import $module, os.path; print os.path.realpath($module.__file__)[:-4] + '.py'"
}
#trap 'echo "$program($LINENO): Command failed with error code $? ($0 $*)"; exit 1' ERR