From 435f2140dadf0ff68ffe918b962b22b07172bf2f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 08:14:59 +0100 Subject: [PATCH] cleanly set suffix Signed-off-by: Nico Schottelius --- ccollect.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index bac7f2f..a0c6489 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -108,13 +108,17 @@ pcmd() delete_from_file() { file="$1"; shift - [ $# -eq 1 ] && suffix="$1" && shift # set if deleting incomplete backups + suffix="" # It will be set, if deleting incomplete backups. + [ $# -eq 1 ] && suffix="$1" && shift while read to_remove; do set -- "$@" "${to_remove}" - [ "$suffix" ] && set -- "$@" "$(echo ${to_remove} | sed "s/$suffix\$//")" + if [ "$suffix" ]; then + to_remove_no_suffix="$(echo ${to_remove} | sed "s/$suffix\$//")" + set -- "$@" "${to_remove_no_suffix}" + fi done < "${file}" _techo "Removing $@ ..." - pcmd echo rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." + pcmd rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." } display_version()