summaryrefslogtreecommitdiffstats
path: root/src/util/unix.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/unix.rs')
-rw-r--r--src/util/unix.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/unix.rs b/src/util/unix.rs
index 61d41fb..2d71359 100644
--- a/src/util/unix.rs
+++ b/src/util/unix.rs
@@ -56,6 +56,16 @@ pub fn mode_to_string(mode: u32) -> String {
mode_str
}
+pub fn expand_shell_string_cow(s: &str) -> std::borrow::Cow<'_, str> {
+ let dir = dirs_next::home_dir();
+ let os_str = dir.map(|s| s.as_os_str().to_owned());
+ let context_func = || {
+ let cow_str = os_str.as_ref().map(|s| s.to_string_lossy());
+ cow_str
+ };
+ shellexpand::tilde_with_context(s, context_func)
+}
+
pub fn expand_shell_string(s: &str) -> path::PathBuf {
let dir = dirs_next::home_dir();
let os_str = dir.map(|s| s.as_os_str().to_owned());