helpers:shellquote: stringify argument

fixes #34
This commit is contained in:
Jörg Thalheim 2017-04-17 16:48:33 +02:00
parent 941e50294a
commit 5b9b4961d8
No known key found for this signature in database
GPG Key ID: CA4106B8D7CC79FA
1 changed files with 3 additions and 1 deletions

View File

@ -12,6 +12,7 @@ local pairs = pairs
local rawget = rawget
local require = require
local tonumber = tonumber
local tostring = tostring
local io = {
open = io.open,
popen = io.popen
@ -137,7 +138,8 @@ end
-- }}}
-- {{{ Escape a string for safe usage on the command line
function helpers.shellquote(s)
function helpers.shellquote(arg)
local s = tostring(arg)
if s == nil then return "" end
-- use single quotes, and put single quotes into double quotes
-- the string $'b is then quoted as '$'"'"'b'"'"'