From 0e645569b08074edadaca41912ff05bde585e33a Mon Sep 17 00:00:00 2001 From: Sayan Nandan Date: Thu, 7 Oct 2021 23:52:35 -0700 Subject: [PATCH] Fix quote inputs to skysh for whitespaced vals If the matched group has a starting 0x22, only then remove the trailing quotes. Similarly, if the matched group has a starting 0x27, only then remove the trailing quote. Signed-off-by: Sayan Nandan --- CHANGELOG.md | 1 + libsky/src/lib.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6509175b..8e06feca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ All changes in this project will be noted in this file. ### Fixes - Fixed unexpected removal of single and double quotes from input strings in `skysh` +- Fixed incorrect removal of quotes from input strings in `skysh` ## Version 0.7.0 diff --git a/libsky/src/lib.rs b/libsky/src/lib.rs index 18fa5249..918ea3ce 100644 --- a/libsky/src/lib.rs +++ b/libsky/src/lib.rs @@ -70,11 +70,16 @@ pub fn split_into_args(q: &str) -> Vec { let mut chars = v.chars(); let first = chars.next(); let last = chars.last(); - if let Some('"' | '\'') = first { + if let Some('"') = first { v = &v[1..]; - } - if let Some('"' | '\'') = last { - v = &v[..v.len()]; + if let Some('"') = last { + v = &v[..v.len()]; + } + } else if let Some('\'') = first { + v = &v[1..]; + if let Some('\'') = last { + v = &v[..v.len()]; + } } v.to_owned() })