loader: make disable-device more rebust
Check the number of arguments and ensure that the passed-in device to disable parses correctly. Sponsored by: Netflix
This commit is contained in:
+9
-1
@@ -235,9 +235,17 @@ cli["disable-device"] = function(...)
|
||||
return
|
||||
end
|
||||
|
||||
if #argv > 1 then
|
||||
print("Too many arguments")
|
||||
print("usage error: disable-device device")
|
||||
return
|
||||
end
|
||||
|
||||
d, u = string.match(argv[1], "(%w*%a)(%d+)")
|
||||
if d ~= nil then
|
||||
if d ~= nil and u ~= nil then
|
||||
loader.setenv("hint." .. d .. "." .. u .. ".disabled", "1")
|
||||
else
|
||||
print("Cannot parse " .. argv[1] .." into driver and unit number.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user