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

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