From 600a3e3965387be38211012fd7351121a17a433d Mon Sep 17 00:00:00 2001 From: Dale Higgs Date: Thu, 23 Jun 2016 10:47:56 -0500 Subject: [PATCH] Allow service data to be passed to shell_command (#2362) --- homeassistant/components/shell_command.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/shell_command.py b/homeassistant/components/shell_command.py index dec518db6ea..17ffad41f93 100644 --- a/homeassistant/components/shell_command.py +++ b/homeassistant/components/shell_command.py @@ -6,6 +6,7 @@ https://home-assistant.io/components/shell_command/ """ import logging import subprocess +import shlex import voluptuous as vol @@ -23,8 +24,6 @@ CONFIG_SCHEMA = vol.Schema({ }), }, extra=vol.ALLOW_EXTRA) -SHELL_COMMAND_SCHEMA = vol.Schema({}) - def setup(hass, config): """Setup the shell_command component.""" @@ -44,8 +43,7 @@ def setup(hass, config): _LOGGER.exception('Error running command: %s', cmd) for name in conf.keys(): - hass.services.register(DOMAIN, name, service_handler, - schema=SHELL_COMMAND_SCHEMA) + hass.services.register(DOMAIN, name, service_handler) return True @@ -64,6 +62,6 @@ def _parse_command(hass, cmd, variables): shell = True else: # template used. Must break into list and use shell=False for security - cmd = [prog] + rendered_args.split() + cmd = [prog] + shlex.split(rendered_args) shell = False return cmd, shell