From 653b9bf99c10a511148ddf38172cc2274ee5dda0 Mon Sep 17 00:00:00 2001 From: Tau Date: Wed, 1 May 2024 11:34:47 +0200 Subject: [PATCH] export: cancel export when trying to delete (#1340) When deleting an export that doesn't exist, the script would instead export the application. --- distrobox-export | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/distrobox-export b/distrobox-export index 8962801640..4f027ad16e 100755 --- a/distrobox-export +++ b/distrobox-export @@ -371,15 +371,19 @@ export_binary() { mkdir -p "${dest_path}" # If we're deleting it, just do it and exit - if [ "${exported_delete}" -ne 0 ] && + if [ "${exported_delete}" -ne 0 ]; then # ensure it's a distrobox exported binary - grep -q "distrobox_binary" "${dest_file}"; then + if ! grep -q "distrobox_binary" "${dest_file}"; then + printf >&2 "Error: %s is not exported.\n" "${exported_bin}" + return 1 + fi if rm -f "${dest_file}"; then printf "%s from %s removed successfully from %s.\nOK!\n" \ "${exported_bin}" "${container_name}" "${dest_path}" return 0 fi + return 1 fi # test if we have writing rights on the file