<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def shell_call(command, **kwargs):
 """Calls shell command with argument substitution. Args: command: command represented as a list. Each element of the list is one token of the command. For example "cp a b" becomes ['cp', 'a', 'b'] If any element of the list looks like '${NAME}' then it will be replaced by value from **kwargs with key 'NAME'. **kwargs: dictionary with argument substitution Returns: output of the command Raises: subprocess.CalledProcessError if command return value is not zero This function is useful when you need to do variable substitution prior running the command. Below are few examples of how it works: shell_call(['cp', 'a', 'b'], a='asd') calls command 'cp a b' shell_call(['cp', '${a}', 'b'], a='asd') calls command 'cp asd b', '${a}; was replaced with 'asd' before calling the command """

  # Regular expression to find instances of '${NAME}' in a string
  CMD_VARIABLE_RE = re.compile('^\\$\\{(\\w+)\\}$')
  command = list(command)
  for i in range(len(command)):
    m = CMD_VARIABLE_RE.match(command[i])
    if m:
      var_id = m.group(1)
      if var_id in kwargs:
        command[i] = kwargs[var_id]
  str_command = ' '.join(command)
  logging.debug('Executing shell command: %s' % str_command)
  return subprocess.check_output(command)