diff --git a/crates/nu-command/src/filters/update.rs b/crates/nu-command/src/filters/update.rs index 0796cde54e..c4daced13b 100644 --- a/crates/nu-command/src/filters/update.rs +++ b/crates/nu-command/src/filters/update.rs @@ -75,6 +75,11 @@ impl Command for Update { example: "[[project, authors]; ['nu', ['Andrés', 'JT', 'Yehuda']]] | update authors {|row| $row.authors | str join ','}", result: Some(Value::List { vals: vec![Value::Record { cols: vec!["project".into(), "authors".into()], vals: vec![Value::test_string("nu"), Value::test_string("Andrés,JT,Yehuda")], span: Span::test_data()}], span: Span::test_data()}), }, + Example { + description: "You can also use a simple command to update 'authors' to a single string", + example: "[[project, authors]; ['nu', ['Andrés', 'JT', 'Yehuda']]] | update authors {|| str join ','}", + result: Some(Value::List { vals: vec![Value::Record { cols: vec!["project".into(), "authors".into()], vals: vec![Value::test_string("nu"), Value::test_string("Andrés,JT,Yehuda")], span: Span::test_data()}], span: Span::test_data()}), + } ] } } @@ -118,11 +123,16 @@ fn update( } } + let input_at_path = match input.clone().follow_cell_path(&cell_path.members, false) + { + Err(e) => return Value::Error { error: Box::new(e) }, + Ok(v) => v, + }; let output = eval_block( &engine_state, &mut stack, &block, - input.clone().into_pipeline_data(), + input_at_path.into_pipeline_data(), redirect_stdout, redirect_stderr, );