()
| 190 | } |
| 191 | |
| 192 | func readSSHConfigLines() ([]string, error) { |
| 193 | configPath := sshConfigPath() |
| 194 | |
| 195 | // Read file |
| 196 | content, err := os.ReadFile(configPath) |
| 197 | if err != nil { |
| 198 | if os.IsNotExist(err) { |
| 199 | // Config doesn't exist, return empty |
| 200 | return []string{}, nil |
| 201 | } |
| 202 | return nil, fmt.Errorf("failed to read config: %w", err) |
| 203 | } |
| 204 | |
| 205 | // Split into lines |
| 206 | lines := strings.Split(string(content), "\n") |
| 207 | |
| 208 | // Remove trailing newline if present (to avoid extra blank line) |
| 209 | if len(lines) > 0 && lines[len(lines)-1] == "" { |
| 210 | lines = lines[:len(lines)-1] |
| 211 | } |
| 212 | |
| 213 | return lines, nil |
| 214 | } |
| 215 | |
| 216 | func writeSSHConfigLines(lines []string) error { |
| 217 | configPath := sshConfigPath() |
no test coverage detected