UnsetGlobalOption removes a global configuration option
(key string)
| 118 | |
| 119 | // UnsetGlobalOption removes a global configuration option |
| 120 | func UnsetGlobalOption(key string) error { |
| 121 | // Normalize key |
| 122 | key = normalizeConfigKey(key) |
| 123 | |
| 124 | // Load existing config |
| 125 | cfg, found, err := LoadGlobalConfig() |
| 126 | if err != nil { |
| 127 | return err |
| 128 | } |
| 129 | if !found { |
| 130 | return fmt.Errorf("Host * block not found") |
| 131 | } |
| 132 | |
| 133 | // Clear the option value |
| 134 | if err := setConfigField(cfg, key, ""); err != nil { |
| 135 | return err |
| 136 | } |
| 137 | |
| 138 | // Write back |
| 139 | return WriteGlobalConfig(cfg) |
| 140 | } |
| 141 | |
| 142 | // normalizeConfigKey normalizes a config key to standard SSH format |
| 143 | // Converts various formats to the canonical SSH config key format |
no test coverage detected