diff --git a/crates/nu-command/src/platform/kill.rs b/crates/nu-command/src/platform/kill.rs index 3c762db768..4bf310de0a 100644 --- a/crates/nu-command/src/platform/kill.rs +++ b/crates/nu-command/src/platform/kill.rs @@ -2,8 +2,8 @@ use nu_engine::CallExt; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ast::Call, span}; use nu_protocol::{ - Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Spanned, SyntaxShape, - Value, + Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, + Signature, Spanned, SyntaxShape, Value, }; use std::process::{Command as CommandSys, Stdio}; @@ -128,9 +128,22 @@ impl Command for Kill { .stderr(Stdio::null()); } - cmd.status().expect("failed to execute shell command"); - - Ok(Value::Nothing { span: call.head }.into_pipeline_data()) + let output = cmd.output().expect("failed to execute shell command"); + let val = String::from( + String::from_utf8(output.stdout) + .expect("failed to convert output to string") + .trim_end(), + ); + if val.is_empty() { + Ok(Value::Nothing { span: call.head }.into_pipeline_data()) + } else { + Ok(vec![Value::String { + val, + span: call.head, + }] + .into_iter() + .into_pipeline_data(engine_state.ctrlc.clone())) + } } fn examples(&self) -> Vec {