def quotestr(v):
    """Quote a string value to be output."""
    if not v:
        v = '""'
    elif " " in v or "\t" in v or '"' in v or "=" in v:
        v = '"%s"' % v.replace(r'"', r"\"")
    return v