import shlex


def find_argument_quoted(pos, text):
    """
    Get the number of the argument at position pos in
    a string with possibly quoted text.
    """
    sh = shlex.shlex(text)
    count = -1
    w = sh.get_token()
    while w and w[2] is not None:
        count += 1
        if w[0] <= pos < w[1]:
            return count
        w = sh.get_token()

    return count + 1