7047 Commits

Author SHA1 Message Date
3e37922537 Bump ureq, get redirect history. (#16078) 2025-08-02 13:55:37 +02:00
da9615f971 Fix parse-time pipeline type checking to support multiple output types for same input type (#16111)
# Description
Fixes #15485

This PR changes pipeline checking to keep track of all possible output
types instead of only first type matching input type which appears in
the input/output types. For example, in this command:
```nushell
def foo []: [int -> string, int -> record] {
  # ...
}
```
An `int` input to the command may result in a string or a record to be
output. Before this PR, Nushell would always assume that an `int` input
would cause a `string` output because it's the first matching
input/output type pair. This would cause issues during type checking
where the parser would incorrectly determine the output type. After this
PR, Nushell considers the command to output either a string or a record.

# User-Facing Changes
* Parse-time pipeline type checking now properly supports commands with
multiple pipeline output types for the same pipeline input type

# Tests + Formatting
Added a couple tests

# After Submitting
N/A

---------

Co-authored-by: Bahex <Bahex@users.noreply.github.com>
2025-08-02 09:35:25 +08:00
eb8d2d3206 Refactor: introduce 2 associated functions to PipelineData (#16233)
# Description
As title: this pr is try to introduce 2 functions to `PipelineData`:
1. PipelineData::list_stream --> create a PipelineData::ListStream
2. PipelineData::byte_stream -> create a PipelineData::ByteStream
And use these functions everywhere.

### Reason behind this change
I tried to implement `pipefail` feature, but this would required to
change `PipelineData` from enum to struct. So use these functions can
reduce diff if I finally change to struct. [Discord message
here](https://discord.com/channels/601130461678272522/615962413203718156/1396999539000479784)
is my plan.

# User-Facing Changes
NaN

# Tests + Formatting
NaN

# After Submitting
NaN
2025-08-02 09:30:30 +08:00
ee5b5bd39e fix(input list): don't leak ansi styling, fuzzy match indicator preserves styles (#16276)
- fixes #16200

# Description

|    | Select           | Fuzzy           |
| -- | ---------------- | --------------- |
|  | ![select-before] | ![fuzzy-before] |
|  | ![select-fixed]  | ![fuzzy-fixed]  |

[select-before]:
8fe9136472/select-before.svg
[select-fixed]:
8fe9136472/select-after.svg
[fuzzy-before]:
8fe9136472/fuzzy-before.svg
[fuzzy-fixed]:
8fe9136472/fuzzy-after.svg

Using a custom `dialoguer::theme::Theme` implementation, how `input
list` renders items are overridden.

Unfortunately, implementing one of the methods requires
`fuzzy_matcher::skim::SkimMatcherV2` which `dialoguer` does not export
by itself.
Had to add an explicit dependency to `fuzzy_matcher`, which we already
depend on through `dialoguer`. Version specification is copied from
`dialoguer`.

# Tests + Formatting
No tests added.
Couldn't find existing tests, not sure how to test this.

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-31 22:42:10 +02:00
d565c9ed01 Fix commit ID hex formatting in gstat (#16309)
Fix commit ID hex formatting in gstat, closes #16307 

Leading zeros are preserved, maintaining the correct hex representation

This issue is relatively easy to fix, but it's not very easy to verify.
However, I have already tested several scenarios, it works for commit
sha like `000baeef`, `000003c7` and `00000002` etc.
2025-07-31 09:59:14 -05:00
89c0e325fa fix panic when ..= syntax is used in stepped ranges (#16231)
Fixes #16185

# Description

Stepped range literals where `..=` precedes the second value no longer
cause a parser panic:

```diff
random int 1..=3..5
-Error:   x Main thread panicked.
-  |-> at crates/nu-protocol/src/engine/state_working_set.rs:400:48
-  `-> slice index starts at 8 but ends at 7
+Error: nu::parser::parse_mismatch
+
+  × Parse mismatch during operation.
+   ╭─[entry #1:1:15]
+ 1 │ random int 1..=3..5
+   ·               ─┬
+   ·                ╰── expected number
```
2025-07-30 23:38:59 +02:00
7203138880 Bump version to 0.106.2 (#16295) 2025-07-30 01:36:35 +02:00
459f3c0c28 feat(watch): implement --debounce flag with duration (#16187)
- fixes #16178
- `watch --debounce-ms` deprecated

Co-authored-by: Luca Scherzer <luca.scherzer@de.clara.net>
2025-07-29 17:10:40 +03:00
2e4900f085 Check type of row conditions at parse-time (#16175)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

As a bonus to #16174, I realized it would be trivial to add a similar
check to where.

Before:
```nushell
1..100 | where 1
# => no output...
```

After:
```nushell
1..100 | where 1
# => Error: nu::parser::type_mismatch
# => 
# =>   × Type mismatch.
# =>    ╭─[entry #3:1:16]
# =>  1 │ 1..100 | where 1
# =>    ·                ┬
# =>    ·                ╰── expected bool, found int
# =>    ╰────
```

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
* `where` should now error on row condition expressions which are not
booleans
  
# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->
Added test

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
N/A
2025-07-28 22:24:12 -04:00
c921eadc6a Don't import IoError on nu-plugin-core without local-socket (#16279)
When you use `nu-plugin-core` without the `local-socket` feature, you
got the warning:
<img width="1182" height="353" alt="image"
src="https://github.com/user-attachments/assets/dd80af11-4963-4d48-8c93-43e6c2dabafa"
/>

This PR fixes that warning.
2025-07-28 20:10:17 +02:00
00ac34d716 Port unsafe_op_in_unsafe_fn fix to FreeBSD (#16275)
Same general idea as https://github.com/nushell/nushell/pull/16266

Fixes the 2024 edition
[`unsafe_op_in_unsafe_fn`](https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html)
lint for FreeBSD as well

Add safety comments to both implementations and an assertion before
`MaybeUninit::assume_init`
2025-07-28 08:42:23 +02:00
pin
28a796d5cb Fix #16261 (#16266)
- this PR should close #16261 
- fixes #16261

Confirmed to build with Rust-1.86 and to yield a working binary.
2025-07-27 21:27:35 +02:00
f8698a6c24 fix(get): run_const uses --optional flag (#16268)
`Get::run_const()` was not update along `Get::run()` in #16007.

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-27 18:17:33 +03:00
48bca0a058 Reapply "refactor(completion, parser): move custom_completion info from Expression to Signature" (#16250) (#16259)
This reverts commit aeb517867e. The
Nushell version has bumped, so it's okay to reapply the changes from
https://github.com/nushell/nushell/pull/15613.
2025-07-25 19:57:00 -04:00
f3d92e3fa1 fix bare interpolation regression (#16235)
Regression from #16204 

Before:

![](f1995bc71f/before.svg)

After:

![](f1995bc71f/after.svg)

# Tests + Formatting
+1

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-25 08:19:15 +03:00
57dce8a386 Bump patch version (#16236)
Bump patch version
2025-07-25 03:28:24 +08:00
aeb517867e Revert "refactor(completion, parser): move custom_completion info from Expression to Signature" (#16250)
Reverts nushell/nushell#15613 because we haven't bumped to the 106.1 dev
version yet
2025-07-24 15:10:47 -04:00
71baeff287 refactor(completion, parser): move custom_completion info from Expression to Signature (#15613)
Restricts custom completion from universal to internal arguments only.

Pros:
1. Less memory
2. More flexible for later customizations, e.g. #14923 

Cons:
1. limited customization capabilities, but at least covers all currently
existing features in nushell.

# Description

Mostly vibe coded by [Zed AI](https://zed.dev/ai) with a single prompt.
LGTM, but I'm not so sure @ysthakur 

# User-Facing Changes

Hopefully none.

# Tests + Formatting

+3

# After Submitting

---------

Co-authored-by: Yash Thakur <45539777+ysthakur@users.noreply.github.com>
2025-07-24 14:21:58 -04:00
1b01625e1e Bump to 0.106.0 (#16222)
Bump to 0.106.0
2025-07-23 22:54:21 +08:00
51265b262d fix: highlighting a where command with invalid arguments can duplicate text (#16192)
- fixes #16129

# Description

## Problem
Parsing a multi span value as RowCondition always produces a RowCondition
expression that covers all the spans.

Which is problematic inside OneOf and can produce multiple expressions with
overlapping spans.
Which results in funky highlighting that duplicates text.

## Solution
Only reason for including `SyntaxShape::Closure` in the signature (#15697) was
for documentation purposes, making it clear in `help` texts that a closure can
be used as the argument.

As our current parser is shape directed, simplifying the command signature
means simplifies the parsing, so using a RowCondition on its own, and instead
making it always look like a union with `closure(any)` solves the issue without
any changes in the parser.

Also, RowCondition always accepts closure values anyway, so its textual
representation should indicate that without the need to wrap it in OneOf.

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-22 17:24:21 +03:00
889fe7f97b Add KillLine to the EditCommand parser (#16221)
# Description
Follow-up to https://github.com/nushell/reedline/pull/901
Closes https://github.com/nushell/reedline/issues/935

# User-Facing Changes
You can now use `{edit: KillLine}` to mimic emacs `Ctrl-K` behavior`
2025-07-22 14:12:24 +02:00
93b407fa88 Fix the nu-path fuzz-target (#16188)
This code didn't compile, fixed provisionally by always running the
codepath with tilde expansion.

@IanManske worth discussing what we may want to fuzz here.
2025-07-22 14:10:25 +02:00
b0687606f7 group by to table empty (#16219)
- fixes #16217

# Description

> `group-by --to-table` does not always return a table (a list)
> ```nushell
> [] | group-by --to-table something
> #=> ╭──────────────╮
> #=> │ empty record │
> #=> ╰──────────────╯
> ```

Fixed:
```nushell
[] | group-by --to-table something
#=> ╭────────────╮
#=> │ empty list │
#=> ╰────────────╯
```

# Tests + Formatting
+1 test

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-22 14:07:55 +02:00
30c38b8c49 fix(parser): repeated ( / parenthesis / opened sub-expressions causes memory leak (#16204)
- fixes #16186

# Description

Don't attempt further parsing when there is no complete sub-expression.

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-21 08:14:35 +03:00
16167a25ec Fix typo in glob example description ("files for folders" → "files or folders") (#16206)
This pull request fixes a typo in the description of a `glob` example:

**Before:**
```
  Search for files for folders that do not begin with c, C, b, M, or s
  > glob "[!cCbMs]*"
```
**After:**
```
  Search for files or folders that do not begin with c, C, b, M, or s
  > glob "[!cCbMs]*"
```
2025-07-18 18:49:50 -05:00
38009c714c feat(completion): enable nucleo's prefer_prefix option (#16183)
cc: @blindFS @ysthakur

# Description
Enable `nucleo`'s `prefer_prefix` configuration option.
Ranks suggestions with matches closer to the start higher than
suggestions that have matches further from the start.

Example: suggestions based on `reverse`:
<table>
<tr>
<td width=200>Before</td>
<td width=200>After</td>
</tr>
<tr>
<td>

```
bytes reverse
polars reverse
reverse
str reverse
```

</td>
<td>


```
reverse
str reverse
polars reverse
bytes reverse
```

</td>
</tr>
</table>

# User-Facing Changes
More relevant suggestions with fuzzy matching algorithm.
(`$env.config.completions.algorithm = "fuzzy"`)

# Tests + Formatting
We might want to add tests to make sure this option keeps working in the
future.

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-17 22:16:55 -04:00
0b7c246bf4 Check for interrupt before each IR instruction (#16134)
# Description
Fixes #15308. Surprisingly, I can't find any more issues that bring this
up.

This PR adds a check for interrupt before evaluating each IR
instruction. This makes it possible to ctrl-c out of things that were
difficult/impossible previously, like:
```nushell
loop {}
```

@devyn also [mentioned
previously](https://discord.com/channels/601130461678272522/615329862395101194/1268674828492083327)
that this might be a feasible option, but mentioned some performance
concerns.

I did some benchmarking previously but it turns out tango isn't the
greatest for this. I don't have hard numbers anymore but based on some
experimenting I shared in the Discord it seems like no experimental
option and limiting this to specific instructions should keep the
performance impact minimal.
<details>
<summary>Old benchmarking info</summary>

I did some benchmarks against main. It seems like most benchmarks are
between 1-6% slower, with some oddball exceptions.

The worst case seems to a giant loop, which makes sense since it's
mostly just jumping back to the beginning, meaning we hit the check over
and over again.

With `bench --pretty -n 100 { for i in 0..1000000 { 1 } }`, it seems
like the `ir-interrupt` branch is ~10% slower for this stress case:
```
main: 94ms 323µs 29ns +/- 1ms 291µs 759ns 
ir-interrupt: 103ms 54µs 708ns +/- 1ms 606µs 571ns

(103ms + 54µs + 708ns) / (94ms + 323µs + 29ns) = 1.0925720801438639
```

The performance numbers here aren't great, but they're not terrible
either, and I think the usability improvement is probably worth it here.

<details>
<summary>Tango benchmarks</summary>

```
load_standard_lib                                  [   2.8 ms ...   2.9 ms ]      +3.53%*
record_create_1                                    [ 101.8 us ... 107.0 us ]      +5.12%*
record_create_10                                   [ 132.3 us ... 135.6 us ]      +2.48%*
record_create_100                                  [ 349.7 us ... 354.6 us ]      +1.39%*
record_create_1000                                 [   3.7 ms ...   3.6 ms ]      -1.30%
record_flat_access_1                               [  94.8 us ...  99.9 us ]      +5.35%*
record_flat_access_10                              [  96.2 us ... 101.3 us ]      +5.33%*
record_flat_access_100                             [ 106.0 us ... 111.4 us ]      +5.07%*
record_flat_access_1000                            [ 203.0 us ... 208.5 us ]      +2.69%
record_nested_access_1                             [  95.3 us ... 100.1 us ]      +5.03%*
record_nested_access_2                             [  98.4 us ... 104.6 us ]      +6.26%*
record_nested_access_4                             [ 100.8 us ... 105.4 us ]      +4.56%*
record_nested_access_8                             [ 104.7 us ... 108.1 us ]      +3.23%
record_nested_access_16                            [ 110.6 us ... 115.8 us ]      +4.71%*
record_nested_access_32                            [ 119.0 us ... 124.0 us ]      +4.20%*
record_nested_access_64                            [ 137.4 us ... 142.2 us ]      +3.47%*
record_nested_access_128                           [ 176.7 us ... 181.8 us ]      +2.87%*
record_insert_1_1                                  [ 106.2 us ... 111.9 us ]      +5.35%*
record_insert_10_1                                 [ 111.2 us ... 116.0 us ]      +4.28%*
record_insert_100_1                                [ 134.3 us ... 139.8 us ]      +4.06%*
record_insert_1000_1                               [ 387.8 us ... 417.1 us ]      +7.55%
record_insert_1_10                                 [ 162.9 us ... 171.5 us ]      +5.23%*
record_insert_10_10                                [ 159.5 us ... 166.2 us ]      +4.23%*
record_insert_100_10                               [ 183.3 us ... 190.7 us ]      +4.04%*
record_insert_1000_10                              [ 411.7 us ... 418.7 us ]      +1.71%*
table_create_1                                     [ 117.2 us ... 120.3 us ]      +2.66%
table_create_10                                    [ 144.9 us ... 152.2 us ]      +5.02%*
table_create_100                                   [ 476.0 us ... 484.8 us ]      +1.86%*
table_create_1000                                  [   3.7 ms ...   3.7 ms ]      +1.55%
table_get_1                                        [ 121.6 us ... 127.0 us ]      +4.40%*
table_get_10                                       [ 112.1 us ... 117.4 us ]      +4.71%*
table_get_100                                      [ 124.0 us ... 129.5 us ]      +4.41%*
table_get_1000                                     [ 229.9 us ... 245.5 us ]      +6.75%*
table_select_1                                     [ 111.1 us ... 115.6 us ]      +4.03%*
table_select_10                                    [ 112.1 us ... 118.4 us ]      +5.65%*
table_select_100                                   [ 142.2 us ... 147.2 us ]      +3.53%*
table_select_1000                                  [ 383.5 us ... 370.3 us ]      -3.43%*
table_insert_row_1_1                               [ 122.5 us ... 127.8 us ]      +4.35%*
table_insert_row_10_1                              [ 123.6 us ... 128.6 us ]      +3.99%*
table_insert_row_100_1                             [ 124.9 us ... 131.2 us ]      +5.05%*
table_insert_row_1000_1                            [ 177.3 us ... 182.7 us ]      +3.07%*
table_insert_row_1_10                              [ 225.7 us ... 234.5 us ]      +3.90%*
table_insert_row_10_10                             [ 229.2 us ... 235.4 us ]      +2.69%*
table_insert_row_100_10                            [ 253.3 us ... 257.6 us ]      +1.69%
table_insert_row_1000_10                           [ 311.1 us ... 318.3 us ]      +2.32%*
table_insert_col_1_1                               [ 107.6 us ... 113.3 us ]      +5.35%*
table_insert_col_10_1                              [ 109.6 us ... 115.3 us ]      +5.27%*
table_insert_col_100_1                             [ 155.5 us ... 159.8 us ]      +2.71%*
table_insert_col_1000_1                            [ 476.6 us ... 480.8 us ]      +0.88%*
table_insert_col_1_10                              [ 167.7 us ... 177.4 us ]      +5.75%
table_insert_col_10_10                             [ 178.5 us ... 194.8 us ]      +9.16%*
table_insert_col_100_10                            [ 314.4 us ... 322.3 us ]      +2.53%*
table_insert_col_1000_10                           [   1.7 ms ...   1.7 ms ]      +1.35%*
eval_interleave_100                                [ 485.8 us ... 506.5 us ]      +4.27%
eval_interleave_1000                               [   3.3 ms ...   3.2 ms ]      -1.51%
eval_interleave_10000                              [  31.5 ms ...  31.0 ms ]      -1.80%
eval_interleave_with_interrupt_100                 [ 473.2 us ... 479.6 us ]      +1.35%
eval_interleave_with_interrupt_1000                [   3.2 ms ...   3.2 ms ]      -1.26%
eval_interleave_with_interrupt_10000               [  32.3 ms ...  31.1 ms ]      -3.81%
eval_for_1                                         [ 124.4 us ... 130.1 us ]      +4.60%*
eval_for_10                                        [ 124.4 us ... 130.3 us ]      +4.80%*
eval_for_100                                       [ 134.5 us ... 141.5 us ]      +5.18%*
eval_for_1000                                      [ 222.7 us ... 244.0 us ]      +9.59%*
eval_for_10000                                     [   1.0 ms ...   1.2 ms ]     +13.86%*
eval_each_1                                        [ 146.9 us ... 153.0 us ]      +4.15%*
eval_each_10                                       [ 152.3 us ... 158.8 us ]      +4.26%*
eval_each_100                                      [ 169.3 us ... 175.6 us ]      +3.76%*
eval_each_1000                                     [ 346.8 us ... 357.4 us ]      +3.06%*
eval_each_10000                                    [   2.1 ms ...   2.2 ms ]      +2.37%*
eval_par_each_1                                    [ 194.3 us ... 203.5 us ]      +4.73%*
eval_par_each_10                                   [ 186.4 us ... 193.1 us ]      +3.59%*
eval_par_each_100                                  [ 213.5 us ... 222.2 us ]      +4.08%*
eval_par_each_1000                                 [ 433.4 us ... 437.4 us ]      +0.93%
eval_par_each_10000                                [   2.4 ms ...   2.4 ms ]      -0.40%
eval_default_config                                [ 406.3 us ... 414.9 us ]      +2.12%*
eval_default_env                                   [ 475.7 us ... 495.1 us ]      +4.08%*
encode_json_100_5                                  [ 132.7 us ... 128.9 us ]      -2.88%*
encode_json_10000_15                               [  35.5 ms ...  34.0 ms ]      -4.15%*
encode_msgpack_100_5                               [  85.0 us ...  83.9 us ]      -1.20%*
encode_msgpack_10000_15                            [  22.2 ms ...  21.7 ms ]      -2.17%*
decode_json_100_5                                  [ 431.3 us ... 421.0 us ]      -2.40%*
decode_json_10000_15                               [ 119.7 ms ... 117.6 ms ]      -1.76%*
decode_msgpack_100_5                               [ 160.6 us ... 151.1 us ]      -5.90%*
decode_msgpack_10000_15                            [  44.0 ms ...  43.1 ms ]      -2.12%*
```

</details>

</details>

# User-Facing Changes
* It should be possible to ctrl-c in situations where it was not
previously possible

# Tests + Formatting
N/A

# After Submitting
N/A
2025-07-17 21:41:54 +08:00
7ce66a9b77 Also type-check optional arguments (#16194)
# Description
Type-check all closure arguments, not just required arguments.

Not doing so looks like an oversight.

# User-Facing Changes

Previously, passing an argument of the wrong type to a closure would
fail if the argument is required, but be accepted (ignoring the type
annotation) if the argument is optional:

```
> do {|x: string| $x} 4
Error: nu:🐚:cant_convert

  × Can't convert to string.
   ╭─[entry #13:1:21]
 1 │ do {|x: string| $x} 4
   ·                     ┬
   ·                     ╰── can't convert int to string
   ╰────
> do {|x?: string| $x} 4
4
> do {|x?: string| $x} 4 | describe
int
```

It now fails the same way in both cases.

# Tests + Formatting
Added tests, the existing tests still pass.

Please let me know if I added the wrong type of test or added them in
the wrong place (I didn't spot similar tests in the nu-cmd-lang crate,
so I put them next to the most-related existing tests I could find...

# After Submitting
I think this is minor enough it doesn't need a doc update, but please
point me in the right direction if not.
2025-07-17 21:38:08 +08:00
c2622589ef fix quotation rules (#16089)
# Description
This script as example for demonstration
```nushell
def miku [] { print "Hiii world! 初音ミクはみんなのことが大好きだよ!" }

def main [leek: int, fn: closure] {
  print $"Miku has ($leek) leeks 🩵"
  do $fn
}
```
---

`escape_for_string_arg` quoting strings misses, where `|` and `;` did
split the command into 2+ commands
```console
~:►  nu ./miku.nu '32' '{miku}'
Miku has 32 leeks 🩵
Hiii world! 初音ミクはみんなのことが大好きだよ!
~:►  nu ./miku.nu '32' '{miku};ls|' where type == dir 
Miku has 32 leeks 🩵
Hiii world! 初音ミクはみんなのことが大好きだよ!
╭────┬─────────────┬──────┬────────┬──────────────╮
│  # │    name     │ type │  size  │   modified   │
├────┼─────────────┼──────┼────────┼──────────────┤
│  0 │ Desktop     │ dir  │ 4.0 kB │ 5 months ago │
│  1 │ Documents   │ dir  │ 4.0 kB │ a day ago    │
│  2 │ Downloads   │ dir  │ 4.0 kB │ a day ago    │
│  3 │ Music       │ dir  │ 4.0 kB │ 9 months ago │
│  4 │ Pictures    │ dir  │ 4.0 kB │ 3 weeks ago  │
│  5 │ Public      │ dir  │ 4.0 kB │ 9 months ago │
│  6 │ Templates   │ dir  │ 4.0 kB │ 3 months ago │
│  7 │ Videos      │ dir  │ 4.0 kB │ 9 months ago │
│  8 │ __pycache__ │ dir  │ 4.0 kB │ 3 weeks ago  │
│  9 │ bin         │ dir  │ 4.0 kB │ 3 days ago   │
│ 10 │ repos       │ dir  │ 4.0 kB │ a day ago    │
│ 11 │ trash       │ dir  │ 4.0 kB │ 3 days ago   │
╰────┴─────────────┴──────┴────────┴──────────────╯
```

# User-Facing Changes

This adjustment won't need a change, aside from clarifying the following
behavior, which is unintuitive and potentially ambiguous

```console
~:►  nu ./miku.nu '32' {miku}
Miku has 32 leeks 🩵
Hiii world! 初音ミクはみんなのことが大好きだよ!
~:►  nu ./miku.nu '32' { miku }
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[<commandline>:1:9]
 1 │ main 32 "{ miku }"
   ·         ─────┬────
   ·              ╰── expected block, closure or record
   ╰────

~:►  nu ./miku.nu '32' '{' miku '}'
Miku has 32 leeks 🩵
Hiii world! 初音ミクはみんなのことが大好きだよ!
```
2025-07-17 21:36:06 +08:00
1ba4fe0aac Use correct column name in history import -h example (#16190)
Closes #16189

See that issue for details.
2025-07-16 14:04:56 -05:00
5aa1ccea10 fix rest parameter spans (#16176)
Closes #16071

# Description

Rest parameter variables are now fully spanned, instead of just the
first value:

```diff
def foo [...rest] {
  metadata $rest | view span $in.span.start $in.span.end
}
foo 1 2

-1
+1 2
```
2025-07-16 13:02:48 +03:00
00e9e0e6a9 fix(overlay use): report errors in export-env (#16184)
- fixes #10242

# Tests + Formatting
Added 2 tests to confirm `use` and `overlay use` report errors in
`export-env` blocks.

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-16 10:32:02 +03:00
db1ffe57d3 Panic when converting other I/O errors into our I/O errors (#16160)
# Description
I added a debug-only check that makes sure only non-other I/O errors get
converted.
Since tests run in debug mode, that should help us catch these errors early.

I left the check out in release mode on purpose so we don't crash users who
have nu as their main shell. It's similar to the debug assertions in the same
file that check for unknown spans.
2025-07-16 01:55:02 +03:00
2df00ff498 Revert "Add extern for nu command" (#16180)
Reverts nushell/nushell#16119
2025-07-15 19:18:44 +03:00
c4e8e040ce Add warning when using history isolation with non-SQLite history format (#16151)
# Description
This PR depends on #16147, use `git diff 132ikl/shell-warning
132ikl/isolation-warn` to see only changes from this PR

People seem to get tripped up by this a lot, and it's not exactly
intuitive, so I added a warning if you try to set
`$env.config.history.isolation = true` when using the plaintext file
format:

    Warning: nu:🐚:invalid_config

      ⚠ Encountered 1 warnings(s) when updating config

    Warning: nu:🐚:incompatible_options

      ⚠ Incompatible options
       ╭─[source:1:33]
     1 │ $env.config.history.isolation = true
       ·                                 ──┬─
       ·                                   ╰── history isolation only compatible with SQLite format
       ╰────
      help: disable history isolation, or set $env.config.history.file_format = "sqlite"


# User-Facing Changes
* Added a warning when using history isolation without using SQLite
history.

# Tests + Formatting
Added a test
2025-07-15 16:40:32 +03:00
59ad605e22 Add ShellWarning (#16147)
# Description
Adds a proper `ShellWarning` enum which has the same functionality as
`ParseWarning`.

Also moves the deprecation from #15806 into `ShellWarning::Deprecated`
with `ReportMode::FirstUse`, so that warning will only pop up once now.

# User-Facing Changes
Technically the change to the deprecation warning from #15806 is user
facing but it's really not worth listing in the changelog
2025-07-15 15:30:18 +03:00
5569f5beff Print errors during stdlib testing (#16128)
# Description
This PR adds error output display for stdlib tests. This makes it easier
to understand why a test is failing. Here's what an example error output
looks like:


![image](https://github.com/user-attachments/assets/ed06b53e-c3f9-4c56-a646-7e6486ce7ec6)


# User-Facing Changes
N/A

# Tests + Formatting
N/A

# After Submitting
N/A
2025-07-15 19:28:13 +08:00
4ed522db93 Add default error codes (#16166)
# Description
Before this PR, errors without error codes are printed somewhat
strangely, with the `×` and the description being printed on the same
line as the `Error:` text:

    Error:   × Invalid literal
       ╭─[entry #1:1:2]
     1 │ "\z"
       ·  ─┬─
       ·   ╰── unrecognized escape after '\' in string
       ╰────


This PR adds a default error code for the different error types:

    Error: nu::parser::error

      × Invalid literal
       ╭─[entry #1:1:2]
     1 │ "\z"
       ·  ─┬─
       ·   ╰── unrecognized escape after '\' in string
       ╰────

While maybe not as informative as a proper error code, it makes
`GenericError`s and other things which don't have error codes look a lot
nicer.

It would be nicer if we could just set `diagnostic(code:
"nu:🐚:error")` at the top of `ShellError`, but unfortunately you
can't set a "default" at the `enum` level and then override it in the
variants. @cptpiepmatz mentioned he might change miette's derive macro
to accommodate this, in that case we can switch the approach here.

# User-Facing Changes
* Errors without error codes now have a default error code corresponding
to from which part of Nushell the error occurred (shell, parser,
compile, etc)

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-15 13:42:10 +03:00
beb3ec6a49 refactor(get,select,reject)!: deprecate --ignore-errors in favor of --optional (#16007)
# Description
As decided on the team meeting on 2025-06-19, rename `--ignore-errors
(-i)` to `--optional (-o)` with a (currently) indefinite grace period.

After `--ignore-errors (-i)` is removed, the short flag `-i` can be used
for `--ignore-case` (not implemented as of this PR)

# User-Facing Changes
`get`/`select`/`reject`: rename `--ignore-errors (-i)` to `--optional
(-o)` to better reflect its behavior.

# Tests + Formatting
- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
Update docs and inform third parties that integrate with nushell.

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-15 00:26:41 -04:00
a506d3f9b5 fix(completion): put argument completion results before commands (#16112)
#16075

# Description

# User-Facing Changes

Improved experience: more meaningful items on top of the completion
menu.
Mostly for the fuzzy/substring matcher.

# Tests + Formatting

Adjusted

# After Submitting
2025-07-14 21:35:36 -04:00
316d2d6af2 Add extern for nu command (#16119)
# Description
Adds an `extern` definition (`KnownExternal`) for the `nu` command. This
way you can do `help nu` and get tab completions for flags on the `nu`
executable

# User-Facing Changes
* You can now view the flags for Nushell itself with `help nu`, and tab
completion for flags on `nu` works
2025-07-15 02:26:40 +03:00
202d3b2d11 Polars limit housekeeping (#16173)
# Description
Removed a todo and fixed an example.

---------

Co-authored-by: Jack Wright <jack.wright@nike.com>
2025-07-14 15:32:04 -07:00
288f419f7b print to a value should be a SIGPIPE (#16171)
# Description
Partially handles #14799 
It's difficult to fix all cases there, but I think it's good to improve
one of this with a small step

# User-Facing Changes
Given the following code in c:
```C
// write.c
#include <stdio.h>

int main() {
  while (1) {
    printf("a\n");
  }
}
```
After this pr, `./write | 0` will exit immediately, in that case,
`./write` will receive `SIGPIPE` in unix. Before this pr, `./write | 0`
runs indefinitely.

-----------------------

Maybe it's easier to see what happened internally by the different
output of `view ir { ./write | 0 }` command.
### Before
```
# 2 registers, 6 instructions, 7 bytes of data
   0: load-literal           %1, glob-pattern("./write", no_expand = false)
   1: push-positional        %1
   2: redirect-out           null
   3: call                   decl 135 "run-external", %0
   4: load-literal           %0, int(0)
   5: return                 %0
```

### After
```
# 2 registers, 6 instructions, 7 bytes of data
   0: load-literal           %1, glob-pattern("./write", no_expand = false)
   1: push-positional        %1
   2: redirect-out           pipe      # changed, the command's output is a pipe rather than null
   3: call                   decl 136 "run-external", %0
   4: load-literal           %0, int(0)
   5: return                 %0
```
# Tests + Formatting
Added 1 test.

# After Submitting
NaN
2025-07-14 13:26:51 -04:00
c272fa2b0a Update default (scaffold) config blurb (#16165)
Updates the header for the default generated config file to point people
towards `config nu --doc`, adapting some text from that command.
2025-07-14 11:48:06 -04:00
bfe9d8699d fix: unwrap ShellErrorBridge in ByteStream::into_bytes (#16161)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

- closes #16159 

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

The setup in #16159 produced a `ByteStream` that held the `ShellError`
inside an `std::io::Error`. For exactly this setup is the
`ShellErrorBridge` designed, while figuring out what happened I found
out that inside `BytesStream::into_bytes` a sneaky `ShellErrorBridge`
was hiding:
<img width="1034" height="580" alt="image"
src="https://github.com/user-attachments/assets/a0d16ca6-1a60-4c3c-a4cb-5e4b0695f20c"
/>

To fix this, I try to unwrap the bridge and if that is possible, return
the original `ShellError`. This is done at multiple occasions inside
`byte_stream.rs` already.

With this fix, we get the original error that looks like this:
<img width="1439" height="733" alt="image"
src="https://github.com/user-attachments/assets/73f4dee7-f986-4f68-9c2c-0140a6e9e2b2"
/>


# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

None, just a better error.

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->

To have less situations with other I/O errors, I opened #16160 to find
out faster what other error was passed around.
2025-07-13 12:53:55 -04:00
60ca889443 fix(overlay): overlay use and overlay hide now update config state (#16154)
- fixes #5986
- fixes #7760
- fixes #8856
- fixes #10592
- fixes #11082

# Description
Unconditionally update the config state after each `overlay use` and
`overlay hide`.

The fix looks simple, but only because of the constant improvements and
refactors to the codebase that have taken place over time made it
possible.

Fixing these issue when they were initially filed would have been much
harder.

# User-Facing Changes
Overlays can add hooks, change color_config, update the config in
general.

# Tests + Formatting
No tests added as I still haven't figured out how to simulate the repl
in tests.

# After Submitting
N/A

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-13 02:31:16 +03:00
f48656e18b Bump update-informer to v1.3.0 (#16157)
# Description

This PR bumps `update-informer` to 1.3.0 and gets rid of
`NativeTlsHttpClient`.
2025-07-11 12:11:12 -05:00
172a0c44bd fix(get): to be consistent with regular cell-path access on null values (#16155)
# Description
Cell-path accesses on `null` values throw an error, unless the initial
cell-path member is optional:
```nushell
">"; (null).a
# => Error: nu:🐚:incompatible_path_access
# => 
# =>   x Data cannot be accessed with a cell path
# =>    ,-[source:1:8]
# =>  1 | (null).a
# =>    :        |
# =>    :        `-- nothing doesn't support cell paths
# =>    `----

">"; (null).a? | describe
# => nothing
```

`get` throws an error on `null` even when the cell-path is optional, and
only returns `null` quietly with the `--ignore-errors` flag
```nushell
">"; null | get a?
# => Error: nu:🐚:only_supports_this_input_type
# => 
# =>   x Input type not supported.
# =>    ,-[source:1:1]
# =>  1 | null | get a?
# =>    : ^^|^   ^|^
# =>    :   |     `-- only table or record input data is supported
# =>    :   `-- input type: nothing
# =>    `----

">"; null | get -i a? | describe
# => nothing
```

# Tests + Formatting
No breakage.

# After Submitting
N/A

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-07-11 12:32:31 -04:00
1fcce4cffc fix(gstat): make state entry lowercase (#16153)
A follow up to #15965 based on [this
comment](https://github.com/nushell/nushell/pull/15965#issuecomment-3058106114).

# Description

Make Git state values lowercase instead of title case (as in
[upstream](https://docs.rs/git2/latest/git2/enum.RepositoryState.html)).

# User-Facing Changes

Different values.
2025-07-10 16:14:45 -05:00
8943fcf78d Use Severity::Warning for miette warnings (#16146)
# Description


Changes miette warnings to use `Severity::Warning` instead of the
default `Severity::Error`. This shows them in a different color and with
a different icon:

<img width="650" height="266" alt="image"
src="https://github.com/user-attachments/assets/3ff0d3cf-ab1e-47f2-aff7-586ecea5a32a"
/>


# User-Facing Changes

* Warnings now look less like errors
2025-07-10 20:50:12 +02:00