Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac m芯片 运行脚本报错 line 233: syntax error near unexpected token `}' #199

Closed
Killua67 opened this issue Feb 5, 2025 · 1 comment

Comments

@Killua67
Copy link

Killua67 commented Feb 5, 2025

报错内容

line 233: syntax error near unexpected token `}'

软件版本:

版本: 0.44.11
提交: 1.93.1
日期: fe574d0820377383143b2ea26aa6ae28b3425220
Electron: 2025-01-03T07:59:06.361Z
ElectronBuildId: 30.5.1
Chromium: undefined
Node.js: 124.0.6367.243
V8: 20.16.0
OS: 12.4.254.20-electron.0

Mac 系统 12.7.6

修复

尝试修复脚本 给modify_cursor_app_files 中的 if 判断右括号改为 fi 解决问题。修改后方法如下:


# 修改 Cursor 主程序文件
modify_cursor_app_files() {
    log_info "正在修改 Cursor 主程序文件..."
    
    local files=("$MAIN_JS_PATH" "$CLI_JS_PATH")
    
    for file in "${files[@]}"; do
        if [ ! -f "$file" ]; then
            log_warn "文件不存在: $file"
            continue
        fi
        
        # 创建备份
        local backup_file="${file}.bak"
        if [ ! -f "$backup_file" ]; then
            log_info "正在备份 $file"
            cp "$file" "$backup_file" || {
                log_error "无法备份文件: $file"
                continue
            }
            chmod 644 "$backup_file"
            chown "$CURRENT_USER" "$backup_file"
        else
            log_debug "备份已存在: $backup_file"
        fi
        
        # 读取文件内容
        local content
        content=$(cat "$file") || {
            log_error "无法读取文件: $file"
            continue
        }
        
        # 查找 IOPlatformUUID 位置
        local uuid_pos
        uuid_pos=$(printf "%s" "$content" | grep -b -o "IOPlatformUUID" | cut -d: -f1)
        if [ -z "$uuid_pos" ]; then
            log_warn "未找到 IOPlatformUUID: $file"
            continue
        fi
        
        # 从 UUID 位置向前查找 switch
        local before_uuid="${content:0:$uuid_pos}"
        local switch_pos
        switch_pos=$(printf "%s" "$before_uuid" | grep -b -o "switch" | tail -n1 | cut -d: -f1)
        if [ -z "$switch_pos" ]; then
            log_warn "未找到 switch 关键字: $file"
            continue
        fi
        
        # 构建新的文件内容
        printf "%sreturn crypto.randomUUID();\n%s" "${content:0:$switch_pos}" "${content:$switch_pos}" > "$file" || {
            log_error "无法写入文件: $file"
            continue
        }
        
        chmod 644 "$file"
        chown "$CURRENT_USER" "$file"
        
        log_info "成功修改文件: $file"
    done
}
@yuaotianAI
Copy link

感谢,我这边修复一下~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants