Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow redirection to append to files #10278

Closed
amtoine opened this issue Sep 8, 2023 · 1 comment · Fixed by #10764
Closed

allow redirection to append to files #10278

amtoine opened this issue Sep 8, 2023 · 1 comment · Fixed by #10764
Labels
enhancement New feature or request needs-design this feature requires design redirection-pipe All related to redirection to files or more complex pipelines with STDERR syntax Changes to the grammar or syntax beyond parser bugfixes
Milestone

Comments

@amtoine
Copy link
Member

amtoine commented Sep 8, 2023

Related problem

i was trying to store the results of multiple benchmarks in the same file at my job.
we have out> which is great but it does not allow to append to a file, it only overwrites it 😢

Describe the solution you'd like

in Bash, one can do

$ echo "foo" > foo.txt
$ echo "bar" > foo.txt
$ echo "baz" >> foo.txt
$ cat foo.txt
bar
baz

Note
foo has been overwritten, but not bar

in Nushell, i think it would be could to be able to

> "foo" out> foo.txt
> "bar" out> foo.txt
> "baz" out>> foo.txt
> open foo.txt
bar
baz

currently, the third line of the Nushell proposition gives the following error

Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #6:1:1]
 1  "baz" out>> foo.txt
   ·       ──┬──
   ·         ╰── expected operator
   ╰────

Describe alternatives you've considered

using the save --append command.

the biggest downside of this is that it does not stream 🤔

Additional context and details

No response

@amtoine amtoine added enhancement New feature or request needs-triage An issue that hasn't had any proper look redirection-pipe All related to redirection to files or more complex pipelines with STDERR labels Sep 8, 2023
@sholderbach sholderbach added needs-design this feature requires design syntax Changes to the grammar or syntax beyond parser bugfixes and removed needs-triage An issue that hasn't had any proper look labels Sep 8, 2023
@Silentdoer
Copy link

up

fdncred pushed a commit that referenced this issue Nov 27, 2023
…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
@hustcer hustcer added this to the v0.88.0 milestone Nov 27, 2023
hardfau1t pushed a commit to hardfau1t/nushell that referenced this issue Dec 14, 2023
…ushell#10764)

# Description
Close: nushell#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
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this issue Feb 20, 2024
…ushell#10764)

# Description
Close: nushell#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-design this feature requires design redirection-pipe All related to redirection to files or more complex pipelines with STDERR syntax Changes to the grammar or syntax beyond parser bugfixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants