Skip to content

nushell has no way to provide multi-line commands with error handling #10856

@colemickens

Description

@colemickens

Describe the bug

I just got bit quite hard by wrapping a multiline external command with () only to find out that suppresses error handling.

Take this gist: https://gist.github.com/colemickens/bbee4161334849669b60e6db9e06a511

It produces different results from run1 and run2. This was quite unexpected.

But worse, I don't see any other way of running mult-line commands in nushell without wrapping them in parenthesis, which prevents errors from bubbling up.

To me, this is a grave, fatal flaw, as it stands. I need to be able to author scripts where I call external programs, and be able to format it across lines. The example I've provided is trivial and contrived, but I have many scripts where I'm inadvertently breaking error handling my using multi-line commands right now.

How to reproduce

  1. Take a long line of an external command.
  2. Try to split it across lines.
  3. Use the only facility I see available, wrapping the lines in ()
  4. Notice that it suppresses the error from bubbling.

Expected behavior

Nushell provides a way to enter multiline commands that does not suppress error bubbling.

Screenshots

No response

Configuration

key value
version 0.86.1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.73.0 (cc66ad468 2023-10-03) (built from a source tarball)
cargo_version cargo 1.73.0
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-handlingHow errors in externals/nu code are caught or handled programmatically (see also unhelpful-error)A:external-commandsIssues related to external commandscategory:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions