From 8b0734f719de690742361a8756d25511f2c16029 Mon Sep 17 00:00:00 2001
From: Dennis Camera <dennis.camera@ssrq-sds-fds.ch>
Date: Sun, 13 Oct 2019 10:14:27 +0200
Subject: [PATCH] [__sensible_editor] Improve error message when a basename of
 an editor not in the alternatives is provided

---
 .../__sensible_editor/explorer/editor_path    | 21 ++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/cdist/conf/type/__sensible_editor/explorer/editor_path b/cdist/conf/type/__sensible_editor/explorer/editor_path
index d19a5b06..8a5199c9 100644
--- a/cdist/conf/type/__sensible_editor/explorer/editor_path
+++ b/cdist/conf/type/__sensible_editor/explorer/editor_path
@@ -78,17 +78,24 @@ then
 	if ! $is_abspath
 	then
 		# First, try to resolve the absolute path using $editors.
-		for e in $editors
+		while true
 		do
-			if test "$(basename "${e}")" = "${editor}"
-			then
-				editor="${e}"
-				break
-			fi
+			for e in $editors
+			do
+				if test "$(basename "${e}")" = "${editor}"
+				then
+					editor="${e}"
+					break 2  # break out of both loops
+				fi
+			done
+
+			# Iterating through alternatives did not yield a result
+			editor_no_alternative "${editor}"
+			break
 		done
 	fi
 
-	# Check if path is present
+	# Check if editor is present
 	test -f "${editor}" || editor_missing "${editor}"
 
 	for e in $editors