forked from extern/nushell
Support o>>
, e>>
, o+e>>
to append output to an external file (#10764)
# Description Close: #10278 This pr introduces `o>>`, `e>>`, `o+e>>` to allow redirection to append to a file. Examples: ```nushell echo abc o>> a.txt echo abc o>> a.txt cat asdf e>> a.txt cat asdf e>> a.txt cat asdf o+e>> a.txt ``` ~~TODO:~~ ~~1. currently internal commands with `o+e>` redirect to a variable is broken: `let x = "a.txt"; echo abc o+e> $x`, not sure when it was introduced...~~ ~~2. redirect stdout and stderr with append mode doesn't supported yet: `cat asdf o>>a.txt e>>b.ext`~~ ~~For these 2 items, I'd like to fix them in different prs.~~ Already done in this pr
This commit is contained in:
@@ -528,14 +528,14 @@ pub fn flatten_pipeline_element(
|
||||
flatten_expression(working_set, expr)
|
||||
}
|
||||
}
|
||||
PipelineElement::Redirection(span, _, expr) => {
|
||||
PipelineElement::Redirection(span, _, expr, _) => {
|
||||
let mut output = vec![(*span, FlatShape::Redirection)];
|
||||
output.append(&mut flatten_expression(working_set, expr));
|
||||
output
|
||||
}
|
||||
PipelineElement::SeparateRedirection {
|
||||
out: (out_span, out_expr),
|
||||
err: (err_span, err_expr),
|
||||
out: (out_span, out_expr, _),
|
||||
err: (err_span, err_expr, _),
|
||||
} => {
|
||||
let mut output = vec![(*out_span, FlatShape::Redirection)];
|
||||
output.append(&mut flatten_expression(working_set, out_expr));
|
||||
@@ -545,7 +545,7 @@ pub fn flatten_pipeline_element(
|
||||
}
|
||||
PipelineElement::SameTargetRedirection {
|
||||
cmd: (cmd_span, cmd_expr),
|
||||
redirection: (redirect_span, redirect_expr),
|
||||
redirection: (redirect_span, redirect_expr, _),
|
||||
} => {
|
||||
let mut output = if let Some(span) = cmd_span {
|
||||
let mut output = vec![(*span, FlatShape::Pipe)];
|
||||
|
Reference in New Issue
Block a user