diff options
author | Clint Adams <schizo@debian.org> | 2009-11-14 12:35:24 -0500 |
---|---|---|
committer | Clint Adams <schizo@debian.org> | 2009-11-14 12:35:24 -0500 |
commit | 5dc7063c714ebec3007e684c1a52802145d76620 (patch) | |
tree | 7125a60cbba625a1586b653fb2bb15123b4c956f /savelog | |
parent | 70227f7ce7bcdf169a753354fbdd3e6bbe439096 (diff) | |
download | debianutils-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-- | savelog | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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 |