use helpers.shellquote to escape warg for safe usage on the command line

This commit is contained in:
Shadowmourne G 2015-07-20 21:42:32 +08:00
parent 998aae0990
commit 54186b3151
1 changed files with 2 additions and 1 deletions

View File

@ -8,6 +8,7 @@ local tonumber = tonumber
local io = { popen = io.popen }
local string = { gmatch = string.gmatch }
local setmetatable = setmetatable
local helpers = require("vicious.helpers")
-- }}}
@ -19,7 +20,7 @@ local nvinf = {}
local function worker(format, warg)
if not warg then warg = "0" end
local nv_inf = {}
local f = io.popen("LC_ALL=C nvidia-settings -q GPUUtilization -q [gpu:"..warg.."]/GPUCoreTemp -q [gpu:"..warg.."]/GPUCurrentClockFreqs -t")
local f = io.popen("LC_ALL=C nvidia-settings -q GPUUtilization -q [gpu:"..helpers.shellquote(warg).."]/GPUCoreTemp -q [gpu:"..helpers.shellquote(warg).."]/GPUCurrentClockFreqs -t")
local all_info = f:read("*all")
f:close()