From 2972407b9e51aa130f0f3dd6e28d152d7ad561e8 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 10 Mar 2024 07:12:23 +0100 Subject: [PATCH] builtin read: minor code cleanup --- src/builtins/read.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/builtins/read.rs b/src/builtins/read.rs index f34ba88c6..2bccd3edb 100644 --- a/src/builtins/read.rs +++ b/src/builtins/read.rs @@ -677,11 +677,9 @@ pub fn read(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Opt break; }; let text = tok.text_of(&t); - if let Some(out) = unescape_string(text, UnescapeStringStyle::default()) { - parser.set_var_and_fire(argv[var_ptr], opts.place, vec![out]); - } else { - parser.set_var_and_fire(argv[var_ptr], opts.place, vec![text.to_owned()]); - } + let out = unescape_string(text, UnescapeStringStyle::default()) + .unwrap_or_else(|| text.to_owned()); + parser.set_var_and_fire(argv[var_ptr], opts.place, vec![out]); var_ptr += 1; }