[dune-common] 01/02: get-orig-source: include safe-rm function
Ansgar Burchardt
ansgar at moszumanska.debian.org
Mon Apr 7 12:17:02 UTC 2014
This is an automated email from the git hooks/post-receive script.
ansgar pushed a commit to branch master
in repository dune-common.
commit 36842e82c16ea66d6574a5e2a36c4f551fbc425b
Author: Ansgar Burchardt <burchardt at igpm.rwth-aachen.de>
Date: Mon Apr 7 12:41:29 2014 +0200
get-orig-source: include safe-rm function
safe-rm works like rm, but refuses to follow symlinks.
---
debian/get-orig-source | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/debian/get-orig-source b/debian/get-orig-source
index 79ab9f5..5296df8 100755
--- a/debian/get-orig-source
+++ b/debian/get-orig-source
@@ -26,6 +26,39 @@ usage() {
exit 1
}
+safe-rm() {
+ local -a args
+ args=(--verbose)
+ while [[ $# -gt 0 ]]; do
+ case "${1}" in
+ -*) args+=("${1}"); shift ;;
+ *) break ;;
+ esac
+ done
+
+ local path
+ local n d r
+ for path in "$@"; do
+ r="${path}"
+ d="."
+ while [[ ${r} =~ .*/.* ]]; do
+ n="${r%%/*}"
+ r="${r#*/}"
+ if [[ $n == "" ]]; then
+ d=""
+ continue
+ fi
+ d="${d}/${n}"
+ if [[ -L "${d}" ]]; then
+ echo "safe-rm: ${d} is a symbolic link (while removing ${path})" >&2
+ exit 1
+ fi
+ done
+ done
+
+ rm "${args[@]}" "${@}"
+}
+
if [[ $# -lt 2 ]]; then
usage
fi
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/dune-common.git
More information about the debian-science-commits
mailing list