From fb8633200b1e0bd4009293a5ffad24fbd78f17e5 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 07 Oct 2014 17:04:40 -0400 Subject: cmd/opkg: Factor cleanup code into sig handler cb --- (limited to 'lib') diff --git a/lib/cmd/opkg.sh b/lib/cmd/opkg.sh index cc3c623..795322c 100644 --- a/lib/cmd/opkg.sh +++ b/lib/cmd/opkg.sh @@ -22,12 +22,13 @@ use profile use session use rand +cmd_opkg_opks= + cmd_opkg_main() { local root= local first_arg= local install_cmd= - local opks= local arg= local new_fname= @@ -41,7 +42,7 @@ cmd_opkg_main() first_arg=true install_cmd=false - opks='' + cmd_opkg_opks='' for arg in "${@}"; do if ${first_arg}; then set -- @@ -56,7 +57,9 @@ cmd_opkg_main() fi rand new_fname="/tmp/prokit.${rand_x}.opk" - opks="${opks} ${root}${new_fname}" + cmd_opkg_opks="$(printf '%s %s\n' \ + "${cmd_opkg_opks}" \ + "${root}${new_fname}")" cp "${arg}" "${root}${new_fname}" set -- "${@}" "${new_fname}" ;; @@ -75,13 +78,18 @@ cmd_opkg_main() . "${root}/etc/os-release" profile_set "${ID}" - session_begin "${root}" . : false + session_begin "${root}" . cmd_opkg_fini false session_exec opkg "${@}" session_end - case "${opks}" in + cmd_opkg_fini +} + +cmd_opkg_fini() +{ + case "${cmd_opkg_opks}" in *[!\ ]*) - rm -f ${opks} + rm -f ${cmd_opkg_opks} ;; esac } -- cgit v0.9.1