cleanly set suffix

Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
Nico Schottelius 2009-10-31 08:14:59 +01:00
parent 145c6de2fb
commit 435f2140da

View file

@ -108,13 +108,17 @@ pcmd()
delete_from_file() delete_from_file()
{ {
file="$1"; shift 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 while read to_remove; do
set -- "$@" "${to_remove}" 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}" done < "${file}"
_techo "Removing $@ ..." _techo "Removing $@ ..."
pcmd echo rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." pcmd rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed."
} }
display_version() display_version()