You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[_Notes for plugin developers_](#notes-for-plugin-developers-toc)
36
35
-[_Hall of fame_](#hall-of-fame-toc)
37
36
-[_Full changelog_](#full-changelog-toc)
@@ -67,6 +66,41 @@ As part of this release, we also publish a set of optional plugins you can insta
67
66
for the list of available *containers*
68
67
-->
69
68
69
+
## Non-zero exit codes are now errors
70
+
71
+
One long-requested feature for nushell is to make non-zero exit codes throw an error. Before this release, non-zero exit codes would quietly stop execution. In some cases, execution would not even stop, but rather only skip over the remaining commands in the current code block. With this release, non-zero exit codes (and termination due to unix signals) are now errors just like any other error, so nushell now runs almost as if bash's `set -e` option was enabled ([#13515](https://github.com/nushell/nushell/pull/13515)).
72
+
73
+
Errors due to non-zero exit codes can be caught in a `try`/`catch` block, and the error record passed to the catch closure will contain an `exit_code` column in this case.
74
+
75
+
```nushell
76
+
try {
77
+
nu -c 'exit 42'
78
+
} catch {|e|
79
+
print $e.exit_code? # prints 42
80
+
}
81
+
```
82
+
83
+
As such, `$env.LAST_EXIT_CODE` is no longer necessary in most cases. Rather, `try`/`catch` should suffice for both internal and external errors, unifying and simplifying error handling.
84
+
85
+
Note that the `complete` command still works the same as it does today. If the previous command fails, its exit code and output will still be captured and returned by `complete`.
86
+
87
+
Some other things to note about the current implementation:
88
+
89
+
- Only the exit code of the last command of a pipeline is checked and can cause an error. The exit codes of all the previous commands in a pipeline are ignored. In the future, we may check and track the exit codes of all commands in a pipeline to provide an equivalent to bash's `set -o pipefail`, but this would require a major refactor. So for now, this functionality is only a potential future addition.
90
+
91
+
- If a command was terminated by a unix signal (e.g., SIGTERM, SIGINT), then the `exit_code` value in the `catch` error record will contain the negation of the signal number. For example, if SIGINT is signal number 2, then `exit_code` would be reported as `-2`. This is similar to how Python reports exit codes.
92
+
93
+
- The one exception is SIGPIPE. If a command is terminated due to SIGPIPE, then it is not treated as an error.
94
+
95
+
One downside of having non-zero exit codes as errors is that uncaught errors will print a nushell error message to the terminal which may make it annoying to find any error messages printed by the external command that failed. Similarly, some commands use exit codes to indicate other things besides failure (e.g., `diff`). Having all these extra error message in the REPL can be annoying, so two new config options have been added as well:
96
+
97
+
1.`$env.config.display_errors.exit_code`
98
+
2.`$env.config.display_errors.termination_signal`
99
+
100
+
With no config (e.g., when running a script), these config options are both `true` and the corresponding error cases will be printed as a nushell error message. However, the default config (i.e., `config nu --default`) sets `display_errors.exit_code` to `false`. So, if you use the default config, or set this option in your config, then an error message won't be printed for non-zero exit codes in the REPL.
101
+
102
+
One last thing to note is that core dumps are treated as a separate error case and an error message will always be printed if the error is uncaught (i.e., there is no config option for this).
103
+
70
104
## Removing support for the system clipboard
71
105
72
106
With [#13694](https://github.com/nushell/nushell/pull/13694), support for the system clipboard in keybinds has been removed, as this is not something that we think we can provide good, cross-platform support for in a secure manner. Namely,
@@ -78,14 +112,37 @@ With [#13694](https://github.com/nushell/nushell/pull/13694), support for the sy
78
112
79
113
So, going forward, users that want the system clipboard functionality will have to compile a custom build of nushell by enabling the `system-clipboard` cargo feature. As an alternative, we recommend users delegate system clipboard handling to their terminal.
80
114
81
-
# Changes to commands [[toc](#table-of-content)]
115
+
## Record parsing changes
116
+
117
+
Previously, it was impossible to use datetime literals with colons in record literals without adding parentheses. But thanks to [@cyradotpink](https://github.com/cyradotpink) in [#13413](https://github.com/nushell/nushell/pull/13413), this is now possible.
118
+
119
+
```nushell
120
+
# Previously, parentheses were necessary:
121
+
{ foo: (2024-08-13T22:11:09) }
122
+
123
+
# But this now works!
124
+
{ foo: 2024-08-13T22:11:09 }
125
+
```
126
+
127
+
To make this possible, a few changes were made to record parsing. This should not affect most code, but some previously valid code no longer parses successfully. For example:
128
+
129
+
```nushell
130
+
{ :: 1 }
131
+
# This used to parse as { ':': 1 }, but it is now an error.
132
+
```
133
+
134
+
# Changes [[toc](#table-of-content)]
82
135
83
136
## Additions [[toc](#table-of-content)]
84
137
85
138
### `metadata access`
86
139
87
140
Thanks to [@Bahex](https://github.com/Bahex) in [#13785](https://github.com/nushell/nushell/pull/13785), a new `metadata access` command was added. It takes a closure argument, and the first argument to the closure will be the metadata record. Additionally, the pipeline input to `metadata access` will be forwarded to the closure as is. So, unlike the `metadata` command, this new command allows you to get the metadata of a pipeline without consuming the pipeline.
88
141
142
+
### `split cell-path`
143
+
144
+
In [#13705](https://github.com/nushell/nushell/pull/13705), [@Bahex](https://github.com/Bahex) also added the `split cell-path` command. It is essentially the opposite of `into cell-path` and returns a list of the path members of the input cell path.
145
+
89
146
### `split column --numbered`
90
147
91
148
Thanks to [@nome](https://github.com/nome) in [#13831](https://github.com/nushell/nushell/pull/13831), a `--numbered` flag was added to `split column` which limits the number of times to split the input string (just like `split row --numbered`).
@@ -121,12 +178,19 @@ After [#13650](https://github.com/nushell/nushell/pull/13650), `into record` als
121
178
122
179
### `clear`
123
180
124
-
In [#13821](https://github.com/nushell/nushell/pull/13821), [@T3sT3ro](https://github.com/T3sT3ro) changed the `clear` command to clear the entire scrollback buffer. As such, the `--all` flag was removed, since it is now the default behavior. Instead, a `--keep-scrollback` flag was added, which when used, makes `clear` clear only the terminal (the previous default behavior).
181
+
In [#13821](https://github.com/nushell/nushell/pull/13821), [@T3sT3ro](https://github.com/T3sT3ro) changed the `clear` command to clear the entire scrollback buffer. As such, the `--all` flag was removed, since it is now the default behavior. Instead, a `--keep-scrollback` flag was added which, when used, makes `clear` clear only the terminal (the previous default behavior).
125
182
126
183
### `path exists`
127
184
128
185
After [#13763](https://github.com/nushell/nushell/pull/13763), if an I/O error occurs when checking if a path exists, `false` is now returned instead of throwing an error (this includes errors due to insufficient permissions).
129
186
187
+
### `scope commands` and `help commands`
188
+
189
+
With [#13598](https://github.com/nushell/nushell/pull/13598), two output columns have been renamed for `scope commands` and `help commands`:
190
+
191
+
1.`usage` has been renamed to `description`
192
+
2.`extra_usage` is now `extra_description`
193
+
130
194
## Deprecations [[toc](#table-of-content)]
131
195
132
196
## Removals [[toc](#table-of-content)]
@@ -135,6 +199,10 @@ After [#13763](https://github.com/nushell/nushell/pull/13763), if an I/O error o
135
199
136
200
In [#13693](https://github.com/nushell/nushell/pull/13693), the `str deunicode` command (added in v0.96.0) has been removed due to concerns with stability and support post v1.0.
137
201
202
+
### `$env.config.use_grid_icons`
203
+
204
+
After [#13788](https://github.com/nushell/nushell/pull/13788), the `use_grid_icons` config option has been removed. Instead, the `grid` command now has an `--icons` flag that has the same effect.
205
+
138
206
## Bug fixes and other changes [[toc](#table-of-content)]
139
207
140
208
### `find`
@@ -143,6 +211,14 @@ After [#13848](https://github.com/nushell/nushell/pull/13848), the find command
143
211
144
212
Also, regex patterns are now properly escaped after [#13792](https://github.com/nushell/nushell/pull/13792).
145
213
214
+
### Improved script help output
215
+
216
+
Thanks to [@gwenya](https://github.com/gwenya) in [#13445](https://github.com/nushell/nushell/pull/13445), the help output for scripts now uses the name of the script instead of `main`. The available subcommands are now also listed in the help output.
217
+
218
+
### Bit operations and commands
219
+
220
+
`bits ror` and `bits rol` had undefined behavior in some cases and could also panic in others. This has been fixed in [#13673](https://github.com/nushell/nushell/pull/13673). Similarly, bugs for `bits shl`, `bits shr`, `bit-shl`, and `bit-shr` were fixed in [#13663](https://github.com/nushell/nushell/pull/13663).
221
+
146
222
### `detect columns`
147
223
148
224
One source of panics was fixed in [#13752](https://github.com/nushell/nushell/pull/13752).
@@ -174,16 +250,6 @@ One source of panics was fixed in [#13752](https://github.com/nushell/nushell/pu
0 commit comments