summaryrefslogtreecommitdiff
path: root/savelog
diff options
context:
space:
mode:
authorClint Adams <schizo@debian.org>2009-11-14 12:35:24 -0500
committerClint Adams <schizo@debian.org>2009-11-14 12:35:24 -0500
commit5dc7063c714ebec3007e684c1a52802145d76620 (patch)
tree7125a60cbba625a1586b653fb2bb15123b4c956f /savelog
parent70227f7ce7bcdf169a753354fbdd3e6bbe439096 (diff)
downloaddebianutils-5dc7063c714ebec3007e684c1a52802145d76620.tar.gz
savelog: patch from Patrick Coleman to fix breakage when target file does not exist. closes: #556227.
Diffstat (limited to 'savelog')
-rw-r--r--savelog16
1 files changed, 13 insertions, 3 deletions
diff --git a/savelog b/savelog
index 155c3fb..1adef5d 100644
--- a/savelog
+++ b/savelog
@@ -185,9 +185,9 @@ while [ $# -gt 0 ]; do
continue
fi
- # if not a file or empty, do nothing major
- # (in the Debian version, we rotate even if empty by default)
- if [ ! -s "$filename" ] && [ "$rotateifempty" != "yes" ]; then
+ # if file does not exist or is empty, and we've been told to not rotate
+ # empty files, create if requested and skip to the next file.
+ if [ ! -s "$filename" ] && [ "$rotateifempty" = "no" ]; then
# if -t was given and it does not exist, create it
if test -n "$touch" && [ ! -f "$filename" ]; then
touch -- "$filename"
@@ -199,6 +199,16 @@ while [ $# -gt 0 ]; do
fixfile "$filename"
fi
continue
+ # otherwise if the file does not exist and we've been told to rotate it
+ # anyway, create an empty file to rotate.
+ elif [ ! -e "$filename" ]; then
+ touch -- "$filename"
+ if [ "$?" -ne 0 ]; then
+ echo "$prog: could not touch $filename" 1>&2
+ exitcode=4
+ continue
+ fi
+ fixfile "$filename"
fi
# be sure that the savedir exists and is writable