Skip to content
Discussion options

You must be logged in to vote

This is Nu's multi-line command syntax which allows for calling commands and wrapping their arguments across multiple lines. Your example is exactly as if you wrote assert (4 == 4) "hallo" | print, which outputs nothing since "hallo" is being passed as a second argument to assert and is ignored.

If you want a pipeline to only print "hallo" if the assertion is true, split them up on separate lines, or separate them with a semicolon:

> assert (4 == 4); "hallo" | print
hallo
> assert (4 != 4); "hallo" | print
Error: nu::shell::error

  × Assertion failed.
   ╭─[repl_entry #15:1:8]
 1  assert (4 != 4); "hallo" | print
   ·        ────┬───
   ·            ╰── It is not true.
   ╰────

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@halloleo
Comment options

Answer selected by halloleo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants