nushell
nushell copied to clipboard
Subcommand fails silently when main is not specified
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
- Given the
repro.nuscript below
#!/usr/bin/env nu
# def main [] { }
def 'main subcommand' [] {
print x
}
- Run
nu repro.nu - 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 |