Skip to main content

hardware_enclave/
shell.rs

1// Copyright 2026 Jay Gowdy
2// SPDX-License-Identifier: MIT
3
4//! Shell config block injection and path/value quoting.
5//!
6//! [`BlockMarkers`] + the `install_block_in_file` / `remove_block_from_file`
7//! functions handle adding and removing managed blocks from `.bashrc`,
8//! `.zshrc`, SSH config, and similar files.
9//!
10//! The quoting functions produce correctly-escaped strings for embedding
11//! paths and values into config files.
12
13// Config block management
14pub use crate::internal::core::config_block::{
15    build_block, find_block, has_block, install_block_in_file, read_config_file, remove_block,
16    remove_block_from_file, upsert_block, write_config_file, BlockInstallResult, BlockMarkers,
17    BlockRemoveResult,
18};
19
20// Path and value quoting for config files
21pub use crate::internal::core::quoting::quote_config_value;
22
23/// Quote a filesystem path for embedding in a config file.
24///
25/// On Windows, backslashes are converted to forward slashes (required by
26/// OpenSSH and many other config parsers). Paths containing spaces are
27/// wrapped in double quotes.
28///
29/// Use this wherever you write a path into a generated config file —
30/// SSH `IdentityFile`, `ProxyCommand`, Git credential helper entries, etc.
31pub fn quote_path_for_config(path: &std::path::Path) -> String {
32    crate::internal::core::quoting::quote_ssh_path(path)
33}
34
35/// Quote a path for the `credential_process` directive in AWS config.
36///
37/// Same as [`quote_path_for_config`] but uses INI-style escaping
38/// (`\"` and `\\`) instead of forward-slash normalization.
39pub use crate::internal::core::quoting::quote_credential_process_arg;