summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEl-BG-1970 <elouangros@hotmail.com>2022-04-26 22:22:59 +0200
committerEl-BG-1970 <elouangros@hotmail.com>2022-04-26 22:22:59 +0200
commit0525441139d27ad0c84e2e29a0ee6d1f97c40251 (patch)
tree2269cb29f6c2e9b964468d006523b47745a07e7b
parentb7506a6fdfbc1ba75d263d9011c0521ba3e4e618 (diff)
downloadrush-0525441139d27ad0c84e2e29a0ee6d1f97c40251.tar.gz
~ now works at the beginning of paths
-rw-r--r--src/main.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 4eea403..ec0b9ea 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,7 +7,8 @@ use std::path::Path;
fn substitute_vars(word: &str) -> String {
match word {
"~" => env::var("HOME").unwrap(),
- w if w.chars().nth(0) == Some('$') => String::from_str(w).unwrap(),
+ w if w.chars().nth(0).unwrap() == '~' => w.replace("~", env::var("HOME").unwrap().as_str()),
+ w if w.chars().nth(0).unwrap() == '$' => String::from_str(w).unwrap(),
w => String::from_str(w).unwrap()
}
}