def split_shell_line(line: str, delim: str, expected_length: int) -> list[str]:
    """Processes a split line to remove extra whitespace and quotes, and returns processed list."""
    raw_split = line.split(delim)
    if len(raw_split) != expected_length:
        raise SyntaxError("invalid split line")
    
    processed_list = []
    for item in raw_split:
        # strip whitespace and quotes
        item = item.strip()
        if item.startswith('"') and item.endswith('"'):
            item = item.strip('"')
        elif item.startswith("'") and item.endswith("'"):
            item = item.strip('"')
        processed_list.append(item)
    
    return processed_list