Like capture_file_state, but follows symlinks to capture the resolved
content. For symlinks, is_symlink and symlink_target are recorded AND
the actual file content behind the symlink is read. This is used for
post-apply snapshots where we need to know both the link target and the
content that was accessible through the symlink at the time of capture.
Check if a command is available on the system via PATH lookup.
On Windows, tries common executable extensions (.exe, .cmd, .bat, .ps1, .com)
since executables require an extension to be found.
Create a symbolic link. On Unix, uses std::os::unix::fs::symlink.
On Windows, uses symlink_file or symlink_dir based on the source type.
If symlink creation fails on Windows due to insufficient privileges,
returns an error with guidance to enable Developer Mode or run as admin.
Escape a value for use inside bash/zsh double quotes (single pass).
Escapes \, ", `, and ! — the four characters with special
meaning inside double-quoted strings.
Merge env vars by name: later entries override earlier ones with the same name.
Used by config layer merging, composition, and reconciler module merge.
Resolve a relative path against a base directory with traversal validation.
Absolute paths are returned as-is. Relative paths are joined to base and
validated with validate_no_traversal. Returns Err if the relative path
contains .. components.
Uses single quotes for values containing shell metacharacters ($, backtick,
\, "). Single quotes within the value are escaped via '\''.
Single-pass scan: returns double-quoted string when no metacharacters are present
(zero intermediate allocations in the common case).