diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index d5934fc485..c449c39b9e 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -172,6 +172,16 @@ impl Value { pub fn as_string(&self) -> Result { match self { Value::String { val, .. } => Ok(val.to_string()), + Value::Binary { val, .. } => Ok(match std::str::from_utf8(val) { + Ok(s) => s.to_string(), + Err(_) => { + return Err(ShellError::CantConvert( + "binary".into(), + "string".into(), + self.span()?, + )) + } + }), x => Err(ShellError::CantConvert( "string".into(), x.get_type().to_string(),