def build_command(command, parameter_map):
    """
    Build command line(s) using the given parameter map.

    Even if the passed a single `command`, this function will return a list
    of shell commands.  It is the caller's responsibility to concatenate them,
    likely using the semicolon or double ampersands.

    :param command: The command to interpolate params into.
    :type command: str|list[str]
    :param parameter_map: A ParameterMap object containing parameter knowledge.
    :type parameter_map: valohai_yaml.objs.parameter_map.ParameterMap

    :return: list of commands
    :rtype: list[str]
    """

    if isinstance(parameter_map, list):  # Partially emulate old (pre-0.7) API for this function.
        parameter_map = LegacyParameterMap(parameter_map)

    out_commands = []
    for command in listify(command):
        # Only attempt formatting if the string smells like it should be formatted.
        # This allows the user to include shell syntax in the commands, if required.
        # (There's still naturally the chance for false-positives, so guard against
        #  those value errors and warn about them.)

        if interpolable_re.search(command):
            try:
                command = interpolable_re.sub(
                    lambda match: _replace_interpolation(parameter_map, match),
                    command,
                )
            except ValueError as exc:  # pragma: no cover
                warnings.warn(
                    'failed to interpolate into %r: %s' % (command, exc),
                    CommandInterpolationWarning
                )
        out_commands.append(command.strip())
    return out_commands
Build command line(s) using the given parameter map.

    Even if the passed a single `command`, this function will return a list
    of shell commands.  It is the caller's responsibility to concatenate them,
    likely using the semicolon or double ampersands.

    :param command: The command to interpolate params into.
    :type command: str|list[str]
    :param parameter_map: A ParameterMap object containing parameter knowledge.
    :type parameter_map: valohai_yaml.objs.parameter_map.ParameterMap

    :return: list of commands
    :rtype: list[str]