diff --git a/crates/nu-command/src/conversions/into/binary.rs b/crates/nu-command/src/conversions/into/binary.rs index b0437edc9..18ffdfa7b 100644 --- a/crates/nu-command/src/conversions/into/binary.rs +++ b/crates/nu-command/src/conversions/into/binary.rs @@ -187,12 +187,14 @@ pub fn action(input: &Value, _args: &Arguments, span: Span) -> Value { let val = if cfg!(target_endian = "little") { match val.iter().rposition(|&x| x != 0) { Some(idx) => &val[..idx + 1], - None => &val, + + // all 0s should just return a single 0 byte + None => &[0], } } else { match val.iter().position(|&x| x != 0) { Some(idx) => &val[idx..], - None => &val, + None => &[0], } };