From 74188a07df6f4b929933e4cd8c7c831ed344c6f5 Mon Sep 17 00:00:00 2001 From: Maxime COSTE Date: Thu, 25 Dec 2008 18:57:39 +0100 Subject: [PATCH] awful.completion: escape spaces This patch add a bash_escape function for bash completion, at the moment it only escape spaces, other escaping may easily be added Signed-off-by: Julien Danjou --- lib/awful/completion.lua.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/awful/completion.lua.in b/lib/awful/completion.lua.in index 79edf2020..e4d54f307 100644 --- a/lib/awful/completion.lua.in +++ b/lib/awful/completion.lua.in @@ -39,6 +39,11 @@ function bashcomp_load(src) end end +local function bash_escape(str) + res = str:gsub(" ", "\\ ") + return res +end + --- Use bash completion system to complete command and filename. -- @param command The command line. -- @param cur_pos The cursor position. @@ -96,7 +101,7 @@ function bash(command, cur_pos, ncomp) while true do local line = c:read("*line") if not line then break end - table.insert(output, line) + table.insert(output, bash_escape(line)) end c:close()