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 <julien@danjou.info>
This commit is contained in:
Maxime COSTE 2008-12-25 18:57:39 +01:00 committed by Julien Danjou
parent 3cc60e84dc
commit 74188a07df
1 changed files with 6 additions and 1 deletions

View File

@ -39,6 +39,11 @@ function bashcomp_load(src)
end end
end end
local function bash_escape(str)
res = str:gsub(" ", "\\ ")
return res
end
--- Use bash completion system to complete command and filename. --- Use bash completion system to complete command and filename.
-- @param command The command line. -- @param command The command line.
-- @param cur_pos The cursor position. -- @param cur_pos The cursor position.
@ -96,7 +101,7 @@ function bash(command, cur_pos, ncomp)
while true do while true do
local line = c:read("*line") local line = c:read("*line")
if not line then break end if not line then break end
table.insert(output, line) table.insert(output, bash_escape(line))
end end
c:close() c:close()