def add_extra_ybd_args(ybd_args, extra_args):
    """
    Inserts extra arguments into a list of yb_build.sh arguments. If a "--" argument is present,
    new arguments are inserted before it, because the rest of yb_build.sh's arguments may be passed
    along to yet another command.

    :param ybd_args: existing yb_build.sh arguments
    :param extra_args: extra arguments to insert
    :return: new list of yb_build.sh arguments
    """
    for i in range(len(ybd_args)):
        if ybd_args[i] == '--':
            return ybd_args[:i] + extra_args + ybd_args[i:]

    return ybd_args + extra_args