1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Purpose: Path normalization helpers for filesystem-facing callers.
//!
//! Responsibilities:
//! - Expand supported Unix-style tilde paths into home-directory paths.
//! - Preserve untouched paths when expansion is unsupported or unavailable.
//!
//! Scope:
//! - Leading-tilde path expansion only; temp files, atomic writes, and safeguard dumps live elsewhere.
//!
//! Usage:
//! - Used by config, git, prompt, and other callers that accept user-supplied filesystem paths.
//!
//! Invariants/Assumptions:
//! - Only leading `~` and `~/...` forms are expanded.
//! - If `$HOME` is unset or blank, the original path is returned unchanged.
//! - Username-based tilde expansion and nested tildes are intentionally unsupported.
use ;
/// Expands a leading `~` to the user's home directory (`$HOME`) for Unix-style paths.
///
/// Supported:
/// - `~` → `$HOME`
/// - `~/...` → `$HOME/...`
///
/// Not handled (intentionally):
/// - `~user/...` (username-based expansion)
/// - `.../~/...` (nested tilde)
/// - Windows `%USERPROFILE%` expansion (callers should supply absolute paths)
///
/// If `$HOME` is unset or empty, the input path is returned unchanged.