10478 Commits

Author SHA1 Message Date
f015409253 [nu-std] std-rfc/random: add random choice (#16270)
# Description

Adds `random choice` suggested in #16241.

# User-Facing Changes

New `random` module in `std-rfc` with the `choice` subcommand.

# Tests + Formatting

Unsure how do to do tests. Sampling and a histogram should be enough,
but they'll be non-deterministic.

# 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.
-->

---------

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2025-08-04 20:36:28 +02:00
f33d952adf 'stor create/insert/open' & 'query db' now support JSON columns (#16258)
Co-authored-by: Tim 'Piepmatz' Hesse <git+github@cptpiepmatz.de>
2025-08-04 16:58:21 +02:00
9f4c3a1d10 Fix path relative-to for case-insensitive filesystems (#16310)
fixes #16205 

# Description

1. **Adds fallback**: On case-insensitive filesystems (Windows, macOS),
falls back to case-insensitive comparison when the standard comparison
fails
2. **Maintains filesystem semantics**: Only uses case-insensitive
comparison on platforms where it's appropriate

## Before:
```console
$> "/etc" | path relative-to "/Etc"
Error: nu:🐚:cant_convert

  × Can't convert to prefix not found.
   ╭─[entry #33:1:1]
 1 │ "/etc" | path relative-to "/Etc"
   · ───┬──
   ·    ╰── can't convert string to prefix not found
   ╰────
```

## After:
For Windows and macOS:
```console
$> "/etc" | path relative-to "/Etc" | debug -v
""
```
2025-08-04 22:32:31 +08:00
4f9c0775d9 Change the behavior of --ignore-case and --multiline options for find (#16323)
# Description

Changes the behavior of `--ignore-case` and `--multiline` options for
`find`, to make them more consistent between regex mode and search term
mode, and to enable more options for using find.

# User-Facing Changes

Search term mode is now case-sensitive by default.

`--ignore-case` will make the search case-insensitive in search term
mode. In regex mode, the previous behavior of adding a (?i) flag to the
regex is preserved.

`--multiline` will no longer add a (?m) flag in regex mode. Instead, it
will make the search not split multi-line strings into lists of lines.

closes #16317
closes #16022
2025-08-04 22:27:00 +08:00
d528bb713b Fix UTF-8 multibyte handling in explore inputs (#16325)
# Description
`explore` was reading the byte length for computing:
- `:` command input cursor positions
- `/`/`?` search mode cursor positions
- `:try` input box cursor positions
- search highlighting

Fixed this for the majority of cases by using `unicode_width`, this is
only best effort as terminals don't need to follow those expectations
but for the most cases (traditional language scripts etc.) this should
lead to better result. The only way around the uncertainty would be to
perform the highlighting/cursor marking as we go, but this may not be as
compatible with the `ratatui` framework.

Closes #16312

# User-Facing Changes
Fixed cursor position and search highlighting for non-ASCII characters,
with the caveat mentioned above.

# Tests + Formatting
Manually tested
2025-08-03 21:20:35 +02:00
7cc1a86459 typo: help format filesize has a wrong example (#16336)
Just a small one letter typo in the help command. It should be `kB`

<img width="943" height="688" alt="image"
src="https://github.com/user-attachments/assets/fcca3978-cc0d-483f-b74e-465743213b76"
/>
2025-08-03 13:27:03 +02:00
dfbd98013d Add send: vichangemode to reedline config (#16327)
# Description
Allows custom bindings (non-chord) to send a `edit_mode: vi` mode change
via the new `ReedlineEvent::ViChangeMode`
Takes https://github.com/nushell/reedline/pull/932

# User-Facing Changes
You can now set bindings which change the Vi mode. (This still has the
same rules for defining the key-combination: Only modifiers and single
keys are supported)
To do so send a `vichangemode` event with the `mode` field to set
`normal`, `insert`, or `visual`

```nushell
$env.config.keybindings ++=
	[{
	    name: modechangetest
	    modifier: control
	    keycode: "char_["
	    mode: [vi_normal, vi_insert]
	    event: {send: vichangemode, mode: normal}
	}]

```
2025-08-03 13:23:55 +02:00
2c9f6acc03 Forgo full build in the cargo hack wf (#16328)
We ran out of disk space on Github actions with the build part of this
workflow. We hope that `check` should catch the worst offenders.
2025-08-02 21:04:43 +02:00
007d15ed9f Add multiline example for input command (#16329)
# Description

Adds an example that documents how to use `input --reedline` to collect
multiple lines of input from the user

I also removed an extraneous and inconsistent space in the following
example.

# User-Facing Changes

Documentation addition

# Tests + Formatting

I did not run any tests or autoformatters because of the docs-only
nature of the change, and the fact that I copy-pasted the format from an
existing example. If the autoformatter is unhappy, I apologize.

# After Submitting

This PR should automatically update the docs site at the next release,
so no need to do anything there.

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2025-08-02 21:04:20 +02:00
3e37922537 Bump ureq, get redirect history. (#16078) 2025-08-02 13:55:37 +02:00
1274d1f7e3 Add -h/--help flag to testbin (#16196)
# Description
As title, this pr introduce `-h` flag to testbin, so if I want to see
which testbin I should use, I don't need to look into source code.

### About the change
I don't know if there is any way to get docstring of a function inside
rust code. So I created a trait, and put docstring into it's `help`
method:
```rust
pub trait TestBin {
    // the docstring of original functions are moved here.
    fn help(&self) -> &'static str;
    fn run(&self);
}
```
Take `cococo` testbin as example, the changes are:
```
original cococo function --> Cococo struct, then
1. put the body of `cococo` function into `run` method
2. put the docstring of `cococo` function into `help` method
```

# User-Facing Changes

`-h/--help` flag in testbin is enabled.
```
> nu --testbin -h
Usage: nu --testbin <bin>
<bin>:
chop -> With no parameters, will chop a character off the end of each line
cococo -> Cross platform echo using println!()(e.g: nu --testbin cococo a b c)
echo_env -> Echo's value of env keys from args(e.g: nu --testbin echo_env FOO BAR)
echo_env_mixed -> Mix echo of env keys from input(e.g: nu --testbin echo_env_mixed out-err FOO BAR; nu --testbin echo_env_mixed err-out FOO BAR)
echo_env_stderr -> Echo's value of env keys from args to stderr(e.g: nu --testbin echo_env_stderr FOO BAR)
echo_env_stderr_fail -> Echo's value of env keys from args to stderr, and exit with failure(e.g: nu --testbin echo_env_stderr_fail FOO BAR)
fail -> Exits with failure code 1(e.g: nu --testbin fail)
iecho -> Another type of echo that outputs a parameter per line, looping infinitely(e.g: nu --testbin iecho 3)
input_bytes_length -> Prints the number of bytes received on stdin(e.g: 0x[deadbeef] | nu --testbin input_bytes_length)
meow -> Cross platform cat (open a file, print the contents) using read_to_string and println!()(e.g: nu --testbin meow file.txt)
meowb -> Cross platform cat (open a file, print the contents) using read() and write_all() / binary(e.g: nu --testbin meowb sample.db)
nonu -> Cross platform echo but concats arguments without space and NO newline(e.g: nu --testbin nonu a b c)
nu_repl -> Run a REPL with the given source lines
relay -> Relays anything received on stdin to stdout(e.g: 0x[beef] | nu --testbin relay)
repeat_bytes -> A version of repeater that can output binary data, even null bytes(e.g: nu --testbin repeat_bytes 003d9fbf 10)
repeater -> Repeat a string or char N times(e.g: nu --testbin repeater a 5)
```

# Tests + Formatting
None, all existed tests can guarantee the behavior of testbins doesn't
change.

# After Submitting
NaN
2025-08-02 10:48:07 +08: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
18d5d8aae1 Fixup pre-release checkup workflow (#16305)
Avoid going out of disk by running cargo clean between each build:
https://github.com/taiki-e/cargo-hack#--clean-per-run

Also rename to something shorter for the overview
2025-07-30 23:46:18 +02: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
7f2beb49db Manual GH workflow for cargo hack before release (#16304)
Currently we run this locally on whatever machine the person doing it is
using. With this we have all three major platforms covered and don't
block a personal machine before the release. Also any failures are
visible to everyone if we need to fix something.
2025-07-30 23:05:33 +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
324aaef0af Bump reedline to 0.41.0 (#16220) 2025-07-22 13:57:19 +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
AUX
e263991448 deps: bump sysinfo to v0.36 to improve sys temp command (#16195)
# Description
This PR improves `sys temp` command with component names showing up in
the unit column. See related [`sysinfo`
commit](6a5520459e)
for details.

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

An example of running `sys temp` on my Linux system with the old
version:

```sh
$ nu -c 'sys temp'
╭────┬──────────────────────┬───────┬───────┬──────────╮
│  # │         unit         │ temp  │ high  │ critical │
├────┼──────────────────────┼───────┼───────┼──────────┤
│  0 │ r8169_0_500:00 temp1 │ 47.50 │ 47.50 │        │
│  1 │ Sensor 2             │ 54.85 │ 54.85 │        │
│  2 │ Composite            │ 47.85 │ 51.85 │    87.85 │
│  3 │ Sensor 1             │ 47.85 │ 72.85 │        │
│  4 │ acpitz temp1         │ 16.80 │ 16.80 │        │
│  5 │ acpitz temp2         │ 16.80 │ 16.80 │        │
│  6 │ junction             │ 66.00 │ 66.00 │   110.00 │
│  7 │ mem                  │ 60.00 │ 60.00 │   100.00 │
│  8 │ edge                 │ 57.00 │ 57.00 │   100.00 │
│  9 │ gigabyte_wmi temp4   │ 47.00 │ 47.00 │        │
│ 10 │ gigabyte_wmi temp3   │ 62.00 │ 62.00 │        │
│ 11 │ gigabyte_wmi temp1   │ 40.00 │ 40.00 │        │
│ 12 │ gigabyte_wmi temp6   │ 51.00 │ 51.00 │        │
│ 13 │ gigabyte_wmi temp5   │ 45.00 │ 45.00 │        │
│ 14 │ gigabyte_wmi temp2   │ 40.00 │ 40.00 │        │
│ 15 │ Tccd2                │ 47.00 │ 47.00 │        │
│ 16 │ Tctl                 │ 62.00 │ 62.00 │        │
╰────┴──────────────────────┴───────┴───────┴──────────╯
```
After this PR you can see the name of the components/devices:
```
$ target/debug/nu -c 'sys temp'
╭────┬──────────────────────────────────────────┬───────┬───────┬──────────╮
│  # │                   unit                   │ temp  │ high  │ critical │
├────┼──────────────────────────────────────────┼───────┼───────┼──────────┤
│  0 │ r8169_0_500:00 temp1                     │ 48.50 │ 48.50 │        │
│  1 │ nvme Sensor 1 WD Blue SN5000 1TB         │ 72.85 │ 72.85 │        │
│  2 │ nvme Sensor 2 WD Blue SN5000 1TB         │ 46.85 │ 46.85 │        │
│  3 │ nvme Composite WD Blue SN5000 1TB        │ 51.85 │ 51.85 │    87.85 │
│  4 │ acpitz temp2                             │ 16.80 │ 16.80 │        │
│  5 │ acpitz temp1                             │ 16.80 │ 16.80 │        │
│  6 │ amdgpu edge                              │ 56.00 │ 56.00 │   100.00 │
│  7 │ amdgpu junction                          │ 66.00 │ 66.00 │   110.00 │
│  8 │ amdgpu mem                               │ 58.00 │ 58.00 │   100.00 │
│  9 │ gigabyte_wmi temp4                       │ 47.00 │ 47.00 │        │
│ 10 │ gigabyte_wmi temp6                       │ 51.00 │ 51.00 │        │
│ 11 │ gigabyte_wmi temp3                       │ 48.00 │ 48.00 │        │
│ 12 │ gigabyte_wmi temp5                       │ 44.00 │ 44.00 │        │
│ 13 │ gigabyte_wmi temp2                       │ 40.00 │ 40.00 │        │
│ 14 │ gigabyte_wmi temp1                       │ 40.00 │ 40.00 │        │
│ 15 │ k10temp Tccd2                            │ 48.50 │ 48.50 │        │
│ 16 │ k10temp Tctl                             │ 49.38 │ 49.38 │        │
│ 17 │ nvme Sensor 2 Samsung SSD 970 EVO 500GB  │ 54.85 │ 54.85 │        │
│ 18 │ nvme Sensor 1 Samsung SSD 970 EVO 500GB  │ 47.85 │ 47.85 │        │
│ 19 │ nvme Composite Samsung SSD 970 EVO 500GB │ 47.85 │ 47.85 │    84.85 │
╰────┴──────────────────────────────────────────┴───────┴───────┴──────────╯
```
2025-07-18 07:17:59 +08: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