import shlex


def shell_quote(*args: str) -> str:
    """
    Takes command line arguments as positional args, and properly quotes each argument to make it safe to
    pass on the command line. Outputs a string containing all passed arguments properly quoted.
    
    Uses :func:`shlex.join` on Python 3.8+, and a for loop of :func:`shlex.quote` on older versions.
    
    Example::
    
        >>> print(shell_quote('echo', '"orange"'))
        echo '"orange"'
    
    
    """
    return shlex.join(args) if hasattr(shlex, 'join') else " ".join([shlex.quote(a) for a in args]).strip()