From e16ce1df36faf8383633e0c1d5c25a93b6c52f07 Mon Sep 17 00:00:00 2001 From: "A. Taha Baki" Date: Mon, 31 Jul 2023 15:45:39 +0300 Subject: [PATCH] str-expand: Add Escaping Example (#9841) **Related Issue: #9838** Adds an **example**, how bracoxide/str-expand handles the escaping char `\`. --- crates/nu-command/src/strings/str_/expand.rs | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/nu-command/src/strings/str_/expand.rs b/crates/nu-command/src/strings/str_/expand.rs index de11f10c47..7cbc8d170b 100644 --- a/crates/nu-command/src/strings/str_/expand.rs +++ b/crates/nu-command/src/strings/str_/expand.rs @@ -48,6 +48,30 @@ impl Command for SubCommand { },) }, + Example { + description: "Ignore the next character after the backslash ('\\')", + example: "'A{B\\,,C}' | str expand", + result: Some(Value::List{ + vals: vec![ + Value::test_string("AB,"), + Value::test_string("AC"), + ], + span: Span::test_data() + },) + }, + + Example { + description: "Use double backslashes to add a backslash.", + example: "'A{B\\\\,C}' | str expand", + result: Some(Value::List{ + vals: vec![ + Value::test_string("AB\\"), + Value::test_string("AC"), + ], + span: Span::test_data() + },) + }, + Example { description: "Export comma separated values inside braces (`{}`) to a string list.", example: "\"{apple,banana,cherry}\" | str expand",