@@ -25,11 +25,11 @@ IFS=$'\n'
25
25
26
26
# Versioning
27
27
MY_NAME=" watcherd"
28
- MY_DATE=" 2020 -12-11 "
28
+ MY_DATE=" 2022 -12-17 "
29
29
MY_URL=" https://github.com/devilbox/watcherd"
30
30
MY_AUTHOR=
" cytopia <[email protected] >"
31
31
MY_GPGKEY=" 0xA02C56F0"
32
- MY_VERSION=" 1.0.2 "
32
+ MY_VERSION=" 1.0.3 "
33
33
MY_LICENSE=" MIT"
34
34
35
35
# Default settings
@@ -130,14 +130,16 @@ function action() {
130
130
action=" ${action//% p/ ${directory} } "
131
131
action=" ${action//% n/ ${name} } "
132
132
133
- if eval " ${action} " ; then
133
+ if OUTPUT= " $( eval " ${action} " 2>&1 ) " ; then
134
134
if [ " ${verbose} " -gt " 0" ]; then
135
135
printf " %s: [%s] [OK] %s succeeded: %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${info} " " ${directory} "
136
136
fi
137
137
return 0
138
138
else
139
- if [ " ${verbose} " -gt " 0" ]; then
140
- printf " %s: [%s] [ERR] %s failed: %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${info} " " ${directory} "
139
+ printf " %s: [%s] [ERR] %s failed: %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${info} " " ${directory} " >&2
140
+ printf " %s: [%s] [ERR] %s failed: %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${info} " " ${action} " >&2
141
+ if [ -n " ${OUTPUT} " ]; then
142
+ printf " %s: [%s] [ERR] %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${OUTPUT} " >&2
141
143
fi
142
144
return 1
143
145
fi
@@ -151,14 +153,15 @@ function trigger() {
151
153
# Only run trigger when command has been specified (not empty)
152
154
if [ -n " ${action} " ]; then
153
155
if [ " ${changes} " -eq " 1" ]; then
154
- if eval " ${action} " ; then
156
+ if OUTPUT= " $( eval " ${action} " 2>&1 ) " ; then
155
157
if [ " ${verbose} " -gt " 0" ]; then
156
158
printf " %s: [%s] [OK] %s succeeded: %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " TRIGGER" " ${action} "
157
159
fi
158
160
return 0
159
161
else
160
- if [ " ${verbose} " -gt " 0" ]; then
161
- printf " %s: [%s] [ERR] %s failed: %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " TRIGGER" " ${action} "
162
+ printf " %s: [%s] [ERR] %s failed: %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " TRIGGER" " ${action} " >&2
163
+ if [ -n " ${OUTPUT} " ]; then
164
+ printf " %s: [%s] [ERR] %s\\ n" " ${MY_NAME} " " $( date ' +%Y-%m-%d %H:%M:%S' ) " " ${OUTPUT} " >&2
162
165
fi
163
166
# Also return 0 here in order to not abort the loop
164
167
return 0
0 commit comments