Skip to content

weird behavior with newline in arguments when script accepts ...args #17824

@haras-unicorn

Description

@haras-unicorn

Bug report form

  • I have done a basic search of the issue tracker to find any existing issues that are similar.
  • I have checked that my version is at least the latest stable release available via my installation method.

Describe the bug

I am not quite sure if this is a bug but it caused me headaches that I don't know how to resolve.
So, apparently, when passing arguments containing newlines to a nushell script that accepts ...args, nushell interprets each line as its own command? I tried this with bash and bash seems fine with it even though I know nushell isn't really trying to do what bash does.

How to reproduce

  1. Write nushell script like so and make it executable:
#!/usr/bin/env nu

def main [...args: string] {
  print ...($args)
}
  1. Run ./test.nu a b "c\nd"
  2. Error with output:
a
b
c
Error: nu::shell::external_command

  × External command failed
   ╭─[<commandline>:2:1]
 1 │ main a b c
 2 │ d
   · ┬
   · ╰── Command `d` not found
   ╰────
  help: Did you mean `cd`?

Expected behavior

I'd expect nushell to print normally and not error out.

With a script like so:

#!/usr/bin/env bash
echo "$@"

and invocation ./test.sh a b "c\nd" bash happily prints out:

a b c
d

. I know that technically when passing arguments like so to print it should print out probably something like

a
b
c
d

and not a b c on the same line as bash because I am using splatting. That being said, I was not expecting it to error out.

Configuration

key value
version 0.111.0
major 0
minor 111
patch 0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.93.0 (254b59607 2026-01-19) (built from a source tarball)
cargo_version cargo 1.93.0 (083ac5135 2025-12-15)
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator standard
features default, mcp, network, plugin, rustls-tls, sqlite, trash-support
installed_plugins
experimental_options example=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=false, native-clip=false

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