import pipes


def escape( *args ):
    """
    Returns the arguments joined as a string.  Each argument has any shell
    special characters escaped.
    """
    cmd = ''
    for s in args:
        if cmd: cmd += ' '
        if not s:
            cmd += '""'
        else:
            cmd += pipes.quote(s)
    return cmd