iankelling.org
/
git
/
log-quiet
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ea9d543
)
fix newlines in output
author
Ian Kelling
<iank@fsf.org>
Sun, 11 Aug 2019 23:48:30 +0000
(19:48 -0400)
committer
Ian Kelling
<iank@fsf.org>
Sun, 11 Aug 2019 23:48:30 +0000
(19:48 -0400)
log-once
patch
|
blob
|
history
diff --git
a/log-once
b/log-once
index 5980b811423413ed01a33222112313b42b73ae94..8f2fafeab79c16e5f879db96f836ca1e38d057c3 100755
(executable)
--- a/
log-once
+++ b/
log-once
@@
-17,7
+17,7
@@
append() {
cat >> "$1"
}
log-once() {
cat >> "$1"
}
log-once() {
- local cbase c log x i out file
+ local cbase c log x i out file
o
cbase=/var/local/cron-errors
[[ $EUID == 0 ]] || cbase=$HOME/cron-errors
local help="Usage: log-once [OPTION]... LOG_NAME [LOG_MESSAGE]
cbase=/var/local/cron-errors
[[ $EUID == 0 ]] || cbase=$HOME/cron-errors
local help="Usage: log-once [OPTION]... LOG_NAME [LOG_MESSAGE]
@@
-60,7
+60,7
@@
state in the same directory.
# read stdin for anything which is not just a newline
elif [[ ! -t 0 ]]; then
while read -r x; do
# read stdin for anything which is not just a newline
elif [[ ! -t 0 ]]; then
while read -r x; do
- output+=(
$x
)
+ output+=(
"$x"
)
[[ $x ]] && log=true
done
fi
[[ $x ]] && log=true
done
fi
@@
-80,12
+80,17
@@
state in the same directory.
fi
else
file=${c}1
fi
else
file=${c}1
+ if (( errors == 1 )); then
+ out="tee -a"
+ fi
fi
$out $file <<<"log-once: $(date "+%A, %B %d, %r")"
if [[ $2 ]]; then
$out $file <<<"$2"
else
fi
$out $file <<<"log-once: $(date "+%A, %B %d, %r")"
if [[ $2 ]]; then
$out $file <<<"$2"
else
- $out $file <<<"${output[@]}"
+ for o in "${output[@]}"; do
+ $out $file <<<"$o"
+ done
$out $file
fi
return 0
$out $file
fi
return 0