diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2023-07-01 12:45:57 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2023-07-01 12:45:57 -0400 |
commit | b5cd64c6686cf7871ebe19edd929612f2c626890 (patch) | |
tree | c6758fb682ccf915cb75f9b14c24fd9a29611d29 /src | |
parent | 09bd69e4b1094f0ed9df40ce7c890e1bf55af7f4 (diff) |
upgrade to shellexpand v3
Diffstat (limited to 'src')
-rw-r--r-- | src/util/unix.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/util/unix.rs b/src/util/unix.rs index d32fb7f..5e05473 100644 --- a/src/util/unix.rs +++ b/src/util/unix.rs @@ -57,7 +57,16 @@ pub fn mode_to_string(mode: u32) -> String { } pub fn expand_shell_string(s: &str) -> path::PathBuf { - let tilde_cow = shellexpand::tilde_with_context(s, dirs_next::home_dir); + let dir = dirs_next::home_dir(); + let os_str = dir.map(|s| s.as_os_str().to_owned()); + let context_func = || { + let cow_str = match os_str.as_ref() { + Some(s) => Some(s.to_string_lossy()), + None => None, + }; + cow_str + }; + let tilde_cow = shellexpand::tilde_with_context(s, context_func); let tilde_path = path::PathBuf::from(tilde_cow.as_ref()); tilde_path } |