nushell icon indicating copy to clipboard operation
nushell copied to clipboard

Subcommand fails silently when main is not specified

Open davireis opened this issue 1 year ago • 0 comments

Describe the bug

If you create a script with a subcommand but does not specify an empty main then then running the subcommand has no effect. It should either succeed or fail explicitly.

How to reproduce

  1. Given the repro.nu script below
#!/usr/bin/env nu
# def main [] { }
def 'main subcommand' [] {
	print x
}
  1. Run nu repro.nu
  2. x does not get printed to the screen. If you uncomment the # def main [] {} line then x gets printed to the screen.

Expected behavior

I expected nushell to either print x or generate a failure saying that a main needs to be specified.

Configuration

key value
version 0.98.0
major 0
minor 98
patch 0
branch main
commit_hash 25a15d56f171313dd9e6170d427ba4c580c69ee4
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.81.0-nightly (eeb90cda1 2024-09-04) (built from a source tarball)
cargo_version cargo 1.64.0
build_time 2024-09-18 04:03:30 -04:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash
installed_plugins

davireis avatar Oct 11 '24 18:10 davireis