Browse Source

feat: Improve error handling in configuration modification function

- Added detailed error messages for configuration file modification failures
- Enhanced logging to provide specific guidance for manual configuration updates
- Maintained existing key replacement and addition logic
- Improved user feedback for configuration modification errors
pull/217/head v0.0.76
煎饼果子卷鲨鱼辣椒 4 months ago
parent
commit
89751a79c3
  1. 2
      scripts/run/cursor_mac_id_modifier.sh

2
scripts/run/cursor_mac_id_modifier.sh

@ -178,12 +178,14 @@ modify_or_add_config() {
# key存在,执行替换
if ! sed -i '' -e "s/\"$key\":[[:space:]]*\"[^\"]*\"/\"$key\": \"$value\"/" "$file"; then
log_error "修改配置失败: $key"
log_error "请手动修改配置文件: $file"
return 1
fi
else
# key不存在,添加新的key-value对
if ! sed -i '' -e "s/}$/,\n \"$key\": \"$value\"\n}/" "$file"; then
log_error "添加配置失败: $key"
log_error "请手动修改配置文件: $file"
return 1
fi
fi

Loading…
Cancel
Save