isEnvName reports whether s is a POSIX environment variable name ([A-Za-z_][A-Za-z0-9_]*), the only content ${...} expands.
(s string)
| 244 | // isEnvName reports whether s is a POSIX environment variable name |
| 245 | // ([A-Za-z_][A-Za-z0-9_]*), the only content ${...} expands. |
| 246 | func isEnvName(s string) bool { |
| 247 | if s == "" { |
| 248 | return false |
| 249 | } |
| 250 | for i, r := range s { |
| 251 | switch { |
| 252 | case r == '_' || r >= 'a' && r <= 'z' || r >= 'A' && r <= 'Z': |
| 253 | case r >= '0' && r <= '9' && i > 0: |
| 254 | default: |
| 255 | return false |
| 256 | } |
| 257 | } |
| 258 | return true |
| 259 | } |
| 260 | |
| 261 | // Save rewrites config.yaml. |
| 262 | func (c *Config) Save() error { |