diff --git a/crates/nu-command/src/path/join.rs b/crates/nu-command/src/path/join.rs index ed9dbca96..53c2e5e44 100644 --- a/crates/nu-command/src/path/join.rs +++ b/crates/nu-command/src/path/join.rs @@ -5,8 +5,8 @@ use std::{ use nu_engine::CallExt; use nu_protocol::{ - engine::Command, Example, ListStream, PipelineData, ShellError, Signature, Span, Spanned, - SyntaxShape, Value, + engine::Command, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, + Value, }; use super::PathSubcommandArguments; @@ -63,16 +63,15 @@ the output of 'path parse' and 'path split' subcommands."# append: call.opt(engine_state, stack, 0)?, }; + let metadata = input.metadata(); + match input { PipelineData::Value(val, md) => { Ok(PipelineData::Value(handle_value(val, &args, head), md)) } - PipelineData::ListStream(stream, md) => Ok(PipelineData::ListStream( - ListStream::from_stream( - stream.map(move |val| handle_value(val, &args, head)), - engine_state.ctrlc.clone(), - ), - md, + PipelineData::ListStream(..) => Ok(PipelineData::Value( + handle_value(input.into_value(head), &args, head), + metadata, )), _ => Err(ShellError::UnsupportedInput( "Input data is not supported by this command.".to_string(), diff --git a/crates/nu-command/tests/commands/path/join.rs b/crates/nu-command/tests/commands/path/join.rs index d850f9208..c4d599970 100644 --- a/crates/nu-command/tests/commands/path/join.rs +++ b/crates/nu-command/tests/commands/path/join.rs @@ -31,6 +31,18 @@ fn returns_path_joined_from_list() { assert_eq!(actual.out, expected); } +#[test] +fn drop_one_path_join() { + let actual = nu!( + cwd: "tests", pipeline( + r#"[a, b, c] | drop 1 | path join + "# + )); + + let expected = join_path_sep(&["a", "b"]); + assert_eq!(actual.out, expected); +} + #[test] fn appends_slash_when_joined_with_empty_path() { let actual = nu!(