summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2023-07-01 12:45:57 -0400
committerJeff Zhao <jeff.no.zhao@gmail.com>2023-07-01 12:45:57 -0400
commitb5cd64c6686cf7871ebe19edd929612f2c626890 (patch)
treec6758fb682ccf915cb75f9b14c24fd9a29611d29
parent09bd69e4b1094f0ed9df40ce7c890e1bf55af7f4 (diff)
upgrade to shellexpand v3
-rw-r--r--Cargo.lock23
-rw-r--r--Cargo.toml4
-rw-r--r--src/util/unix.rs11
3 files changed, 32 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock
index cc34d55..d9799aa 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -91,6 +91,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
dependencies = [
"memchr",
+ "once_cell",
+ "regex-automata",
"serde",
]
@@ -695,6 +697,15 @@ dependencies = [
]
[[package]]
+name = "os_str_bytes"
+version = "6.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
name = "pathdiff"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -890,6 +901,12 @@ dependencies = [
]
[[package]]
+name = "regex-automata"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
+
+[[package]]
name = "regex-syntax"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -982,11 +999,13 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "shellexpand"
-version = "2.1.2"
+version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4"
+checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b"
dependencies = [
+ "bstr",
"dirs",
+ "os_str_bytes",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 5879ec4..d483cea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,9 +28,7 @@ rustyline = "^9"
serde = "^1"
serde_derive = "^1"
shell-words = "^1"
-# shellexpand latest is v3 migrate
-# shellexpand = { version = "^3", features = ["full"]}
-shellexpand = "^2"
+shellexpand = { version = "^3", features = ["full"]}
signal-hook = "^0"
structopt = "^0"
termion = "^2"
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
}