Blame SOURCES/0004-src-augtool.c-hopefully-fix-readline-quoting-issues.patch

ca4abe
From f224dd99c7dc4d2ce4340b2d16cae6b1e0ed7c8d Mon Sep 17 00:00:00 2001
ca4abe
From: Pino Toscano <ptoscano@redhat.com>
ca4abe
Date: Fri, 17 May 2019 15:18:50 +0200
ca4abe
Subject: [PATCH] * src/augtool.c: hopefully fix readline quoting issues
ca4abe
ca4abe
Configure the quoting (also using a detector) and word break characters,
ca4abe
so it is possible to autocomplete paths with special characters (like
ca4abe
spaces, which are already quoted by augeas).
ca4abe
---
ca4abe
 src/augtool.c | 12 ++++++++++++
ca4abe
 1 file changed, 12 insertions(+)
ca4abe
ca4abe
diff --git a/src/augtool.c b/src/augtool.c
ca4abe
index b42ef630..31a991eb 100644
ca4abe
--- a/src/augtool.c
ca4abe
+++ b/src/augtool.c
ca4abe
@@ -267,10 +267,22 @@ static char *get_home_dir(uid_t uid) {
ca4abe
     return result;
ca4abe
 }
ca4abe
 
ca4abe
+/* Inspired from:
ca4abe
+ * https://thoughtbot.com/blog/tab-completion-in-gnu-readline
ca4abe
+ */
ca4abe
+static int quote_detector(char *str, int index) {
ca4abe
+    return index > 0
ca4abe
+           && str[index - 1] == '\\'
ca4abe
+           && quote_detector(str, index - 1) == 0;
ca4abe
+}
ca4abe
+
ca4abe
 static void readline_init(void) {
ca4abe
     rl_readline_name = "augtool";
ca4abe
     rl_attempted_completion_function = readline_completion;
ca4abe
     rl_completion_entry_function = readline_path_generator;
ca4abe
+    rl_completer_quote_characters = "\"'";
ca4abe
+    rl_completer_word_break_characters = (char *) " ";
ca4abe
+    rl_char_is_quoted_p = &quote_detector;
ca4abe
 
ca4abe
     /* Set up persistent history */
ca4abe
     char *home_dir = get_home_dir(getuid());
ca4abe
-- 
2ac116
2.29.2
ca4abe