def shell_expand_to_popen(template, values):
  """
  Expand a template like "cp $SOURCE $TARGET/blah" into a list of popen arguments.
  """
  return [expand_variables(item, values) for item in shlex.split(template)]