nushell/crates
Ian Manske 3d008e2c4e
Error on non-zero exit statuses (#13515)
# Description
This PR makes it so that non-zero exit codes and termination by signal
are treated as a normal `ShellError`. Currently, these are silent
errors. That is, if an external command fails, then it's code block is
aborted, but the parent block can sometimes continue execution. E.g.,
see #8569 and this example:
```nushell
[1 2] | each { ^false }
```

Before this would give:
```
╭───┬──╮
│ 0 │  │
│ 1 │  │
╰───┴──╯
```

Now, this shows an error:
```
Error: nu:🐚:eval_block_with_input

  × Eval block failed with pipeline input
   ╭─[entry #1:1:2]
 1 │ [1 2] | each { ^false }
   ·  ┬
   ·  ╰── source value
   ╰────

Error: nu:🐚:non_zero_exit_code

  × External command had a non-zero exit code
   ╭─[entry #1:1:17]
 1 │ [1 2] | each { ^false }
   ·                 ──┬──
   ·                   ╰── exited with code 1
   ╰────
```

This PR fixes #12874, fixes #5960, fixes #10856, and fixes #5347. This
PR also partially addresses #10633 and #10624 (only the last command of
a pipeline is currently checked). It looks like #8569 is already fixed,
but this PR will make sure it is definitely fixed (fixes #8569).

# User-Facing Changes
- Non-zero exit codes and termination by signal now cause an error to be
thrown.
- The error record value passed to a `catch` block may now have an
`exit_code` column containing the integer exit code if the error was due
to an external command.
- Adds new config values, `display_errors.exit_code` and
`display_errors.termination_signal`, which determine whether an error
message should be printed in the respective error cases. For
non-interactive sessions, these are set to `true`, and for interactive
sessions `display_errors.exit_code` is false (via the default config).

# Tests
Added a few tests.

# After Submitting
- Update docs and book.
- Future work:
- Error if other external commands besides the last in a pipeline exit
with a non-zero exit code. Then, deprecate `do -c` since this will be
the default behavior everywhere.
- Add a better mechanism for exit codes and deprecate
`$env.LAST_EXIT_CODE` (it's buggy).
2024-09-07 06:44:26 +00:00
..
nu_plugin_custom_values Fixup serde feature selection in nu-protocol (#13793) 2024-09-06 00:57:36 +02:00
nu_plugin_example Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
nu_plugin_formats Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
nu_plugin_gstat Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
nu_plugin_inc Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
nu_plugin_nu_example Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
nu_plugin_polars Added expression support for polars cumulative (#13799) 2024-09-06 22:03:51 -05:00
nu_plugin_python Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
nu_plugin_query Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
nu_plugin_stress_internals Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
nu-cli Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-cmd-base Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-cmd-extra Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-cmd-lang Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-cmd-plugin Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-color-config Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-command Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-derive-value Use IntoValue in config code (#13751) 2024-09-05 09:44:23 +02:00
nu-engine Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-explore Use IntoValue in config code (#13751) 2024-09-05 09:44:23 +02:00
nu-glob Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-json Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-lsp Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-parser Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-path Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-plugin add version and path to plugin executable help (#13764) 2024-09-03 12:46:36 -05:00
nu-plugin-core Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-plugin-engine Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-plugin-protocol Remove bincode and use MessagePack instead for plugin custom values (#13745) 2024-09-01 17:33:10 +02:00
nu-plugin-test-support Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-pretty-hex Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-protocol Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-std Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nu-system remove cfg_atter tarpaulin (#13739) 2024-08-31 16:45:15 +02:00
nu-table Use IntoValue in config code (#13751) 2024-09-05 09:44:23 +02:00
nu-term-grid Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-test-support Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
nu-utils Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
nuon Setup global cargo lint configuration (#13691) 2024-08-28 23:37:17 +02:00
README.md Correct spelling (#4152) 2021-11-25 11:11:20 -06:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.