changeset 40104:338230555429

packaging: blindly factor out trap's cleanup function in builddeb This commit blindly extracts builddeb's trap routine in a dedicated function. While doing so, I think two bugs are exposed, which will be addressed in the next commits: - single quoting around '$CLEANUP' will always evaluate to the literal '$CLEANUP' regardless of the variable's value. The "if" will always be true. - the removal operation will not expand $PWD (and a variable expansion would need double quotes, anyways.
author muxator <a.mux@inwind.it>
date Tue, 09 Oct 2018 22:16:25 +0200
parents 01425e3c2645
children d3780c8f3180
files contrib/packaging/builddeb
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/packaging/builddeb	Tue Oct 09 21:40:49 2018 +0200
+++ b/contrib/packaging/builddeb	Tue Oct 09 22:16:25 2018 +0200
@@ -13,6 +13,13 @@
 DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian`
 CODENAME=`lsb_release -cs 2> /dev/null || echo unknown`
 DEBFLAGS=-b
+
+cleanup() {
+    if [ '$CLEANUP' ]; then
+        rm -r '$PWD/debian';
+    fi
+}
+
 while [ "$1" ]; do
     case "$1" in
     --distid )
@@ -44,7 +51,7 @@
     esac
 done
 
-trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT
+trap 'cleanup' EXIT
 
 set -u