summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2021-08-09 10:42:51 -0300
committerGitHub <noreply@github.com>2021-08-09 10:42:51 -0300
commit3abd3dad6e8a8c0b310233806b85834f5fca6221 (patch)
treeccbddc8135767b7bd7d13f08d48a90408739a8d1
parentc976c9199d9abc921b267a754d525f3c03c42b8a (diff)
Widget: fix interpretation of ||
Fixes #543
-rw-r--r--src/shell.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/shell.rs b/src/shell.rs
index e82376c..dca6809 100644
--- a/src/shell.rs
+++ b/src/shell.rs
@@ -46,13 +46,13 @@ pub fn widget_last_command() -> Result<()> {
let mut text = String::new();
io::stdin().read_to_string(&mut text)?;
- let replacements = vec![("|", "ඛ"), ("||", "ග"), ("&&", "ඝ")];
+ let replacements = vec![("||", "ග"), ("|", "ඛ"), ("&&", "ඝ")];
let parts = shellwords::split(&text).unwrap_or_else(|_| text.split('|').map(|s| s.to_string()).collect());
for p in parts {
for (pattern, escaped) in replacements.clone() {
- if p.contains(pattern) && p != pattern {
+ if p.contains(pattern) && p != pattern && p != format!("{}{}", pattern, pattern) {
let replacement = p.replace(pattern, escaped);
text = text.replace(&p, &replacement);
}
@@ -60,6 +60,7 @@ pub fn widget_last_command() -> Result<()> {
}
let mut extracted = text.clone();
+
for (pattern, _) in replacements.clone() {
let mut new_parts = text.rsplit(pattern);
if let Some(extracted_attempt) = new_parts.next() {