Skip to content

Documentation on redirect doesn't match behaviour #2152

Closed

Description

@Rots

Note that file redirections are scoped to an expression and apply to all external commands in the expression. In the example below, `out.txt` will contain `hello\nworld`:

> let text = "hello\nworld";
($text | head -n 1; $text | tail -n 1) o> out.txt
hello
> cat out.txt
world
> nu --version
0.112.1

Activity

  1. changed the title [-]Documentation doesn't match with behaviour[/-] [+]Documentation on redirect doesn't match behaviour[/+] on Apr 15, 2026
  2. fdncred commented on Apr 15, 2026

    @fdncred
    Contributor

    I wouldn't be surprised. Code changes fast around here.

  3. Kissaki commented on Jul 11, 2026

    @Kissaki
    Contributor

    nushell/nushell#17604 also reported this.


    Aside from the reported book/stdout_stderr_exit_codes.html#file-redirections, related docs:


    The 0.92.0 release notes

    File redirections (o>, e>, o+e>, etc.) now apply to all external commands inside an expression.

    I searched this repository for e>, o>, err>, out>, subexpression, piping. I was not able to identify release notes that document changed behavior after 0.92.0, and checked the 0.92.0 PR for linked followups or comments.

    Possibly related?:


    As for current behavior, as this submission documents:

    Only the last command in a subexpressions in parentheses gets piped out.

    (nu -c 'print a'; nu -c 'print b') o> test.txt
    # => a
    open test.txt
    # => b
    
    do { nu -c 'print a'; nu -c 'print b' } o> test.txt
    open test.txt
    # => a
    # => b
    
  4. added a commit that references this issue on Jul 11, 2026
    3b562c0
  5. added a commit that references this issue on Jul 11, 2026
    e28fa1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions