mirror of
https://github.com/nushell/nushell.git
synced 2025-04-25 21:58:18 +02:00
Remove quotes from external args (#5846)
* remove quotes from external args * remove internal quotes * correct escaped quotes in string
This commit is contained in:
parent
3c0bccb900
commit
f231a6df4a
@ -411,7 +411,7 @@ impl ExternalCommand {
|
|||||||
|
|
||||||
for arg in self.args.iter() {
|
for arg in self.args.iter() {
|
||||||
let mut arg = Spanned {
|
let mut arg = Spanned {
|
||||||
item: trim_enclosing_quotes(&arg.item),
|
item: remove_quotes(trim_enclosing_quotes(&arg.item)),
|
||||||
span: arg.span,
|
span: arg.span,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -527,6 +527,19 @@ fn trim_enclosing_quotes(input: &str) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_quotes(input: String) -> String {
|
||||||
|
let mut chars = input.chars();
|
||||||
|
|
||||||
|
match chars.next_back() {
|
||||||
|
Some('"') => chars
|
||||||
|
.collect::<String>()
|
||||||
|
.replacen('"', "", 1)
|
||||||
|
.replace(r#"\""#, "\""),
|
||||||
|
Some('\'') => chars.collect::<String>().replacen('\'', "", 1),
|
||||||
|
_ => input,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Receiver used for the RawStream
|
// Receiver used for the RawStream
|
||||||
// It implements iterator so it can be used as a RawStream
|
// It implements iterator so it can be used as a RawStream
|
||||||
struct ChannelReceiver {
|
struct ChannelReceiver {
|
||||||
|
Loading…
Reference in New Issue
Block a user