|
|
0dacba |
From fc2b84a2ecd9a403cb602d2de26d6c1804a3ceac Mon Sep 17 00:00:00 2001
|
|
|
b3507f |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
b3507f |
Date: Fri, 17 May 2019 15:18:50 +0200
|
|
|
0dacba |
Subject: [PATCH 4/9] * 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 = "e_detector;
|
|
|
b3507f |
|
|
|
b3507f |
/* Set up persistent history */
|
|
|
b3507f |
char *home_dir = get_home_dir(getuid());
|
|
|
b3507f |
--
|
|
|
0dacba |
2.31.1
|
|
|
b3507f |
|