trim lines in command

This commit is contained in:
Fernando Herrera 2021-09-25 16:45:02 +01:00
parent 637e4f6e6d
commit 25a776c36b
2 changed files with 7 additions and 8 deletions

View file

@ -1,7 +1,7 @@
use nu_engine::eval_expression;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EvaluationContext};
use nu_protocol::{Signature, SyntaxShape, Value};
use nu_protocol::{ShellError, Signature, SyntaxShape, Value};
pub struct BuildString;
@ -24,13 +24,12 @@ impl Command for BuildString {
call: &Call,
_input: Value,
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
let mut output = vec![];
let output = call
.positional
.iter()
.map(|expr| eval_expression(context, expr).map(|val| val.into_string()))
.collect::<Result<Vec<String>, ShellError>>()?;
for expr in &call.positional {
let val = eval_expression(context, expr)?;
output.push(val.into_string());
}
Ok(Value::String {
val: output.join(""),
span: call.head,

View file

@ -62,7 +62,7 @@ impl Command for Lines {
.filter_map(|s| {
if !s.is_empty() {
Some(Value::String {
val: s.into(),
val: s.trim().into(),
span,
})
} else {