Repository navigation
Commit abc4bcf
authored
fix(cli): the operator's host name falls back to HOSTNAME only when it needs to (#645)
An invalid `HOSTNAME` (say `HOSTNAME=$'\xff'`) failed every CLI command,
even on Linux where `/proc/sys/kernel/hostname` already named the host.
And an empty host name file recorded the host as `unknown` without
trying `HOSTNAME`.
Both came from `Operator::terminal` reading `HOSTNAME` eagerly in
`.or(…)` and dropping an empty name only after the fallback. A new
function, `Operator::host_name` (file contents, lazy `HOSTNAME` read) →
host, now reads `HOSTNAME` only when the file names no host: the file is
missing or unreadable, or it is empty after trimming. An invalid
`HOSTNAME` still fails a command when it is needed, and the host is
`unknown` when neither names one. Its unit test fails on `main` in both
ways and passes with the fix.
Closes #636
> [!NOTE]
> Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus
5.5 (via T3 Code)
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent 1b7dbda commit abc4bcf
1 file changed
Lines changed: 48 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 122 | + | |
126 | 123 | | |
127 | 124 | | |
128 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
129 | 143 | | |
130 | 144 | | |
131 | 145 | | |
| |||
346 | 360 | | |
347 | 361 | | |
348 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
0 commit comments