From c5e7bccee5c1111bc01636d6f566b4ad87de04f2 Mon Sep 17 00:00:00 2001 From: Robert O'Shea Date: Sun, 13 Feb 2022 02:18:27 +0000 Subject: [PATCH] Fixed printing of builtin kill command #4392 (#4447) * Fixed printing of builtin kill command * Fixed fmt and clippy issues for kill command * Uncommented unintentional comments * Fixed wrong code added in kill command * Fixed more fmt issues with kill command --- crates/nu-command/src/platform/kill.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/crates/nu-command/src/platform/kill.rs b/crates/nu-command/src/platform/kill.rs index 3c762db7..4bf310de 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 {