import re


def formatCommandLine(command_line):
    """Format a command line for printing in output"""
    return " ".join(map(lambda s: (' ' in s or '\n' in s) and '"' + 
                        re.sub("\\s+", " ", s) + '"' or s, 
                        command_line))