merelymyself
Repos
30
Followers
11
Following
1

A new type of shell

22652
1097

This site is a site that belongs to me.

0
0

All Algorithms implemented in Rust

13593
1356

Algorithms and Data Structures implemented in JavaScript for beginners, following best practices.

24580
4096

The user-friendly command line shell.

20267
1596

Events

issue comment
Nushell crashes when tab completion removes backticks

Maybe it's just me, but I feel like the first should never change what's on the line; it's just a means to see possible options.

Created at 16 hours ago
pull request opened
make `parse -r` columns return 0-indexed uncapitalised

Description

Fixes #7886.

/home/gabriel/CodingProjects/nushell〉'A|B|C' | parse -r '(\w)\|(\w)\|(\w)'                                                                                             01/29/2023 01:08:29 PM
╭───┬──────────┬──────────┬──────────╮
│ # │ capture0 │ capture1 │ capture2 │
├───┼──────────┼──────────┼──────────┤
│ 0 │ A        │ B        │ C        │
╰───┴──────────┴──────────┴──────────╯

User-Facing Changes

Columns automatically named by parse -r are now 0-indexec and uncapitalised.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Created at 1 day ago

Remove 🆖 comments (#7877)

Noticed several instances of commented out code that should just be deleted. Also a comment on eval_external that was incorrect. All gone now.

Clean up cd.rs (#7876)

Some general cleanup of cd.rs; the permission checking code was a little hard to follow. Reworded comments and variable names, reorganized+renamed the module used for Unix file permissions.

Add 'number' command for enumeration (#7871)

Description

This adds a number command that will enumerate the input, and add an index and item record for each item. The index is the number of the item in the input stream, and item is the original value of the item.

> ls | number | get 14
╭───────┬────────────────────────────╮
│ index │ 14                         │
│       │ ╭──────────┬─────────────╮ │
│ item  │ │ name     │ crates      │ │
│       │ │ type     │ dir         │ │
│       │ │ size     │ 832 B       │ │
│       │ │ modified │ 2 weeks ago │ │
│       │ ╰──────────┴─────────────╯ │
╰───────┴────────────────────────────╯

User-Facing Changes

This adds a number command.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Expose filtering by file type in glob (#7834)

Description

Add flags for filtering the output of glob by file type. I find myself occasionally wanting to do this, and getting a file's file_type is presumably fast to do as it doesn't have to go through the fallible metadata method.

The design of the signature does concern me; it's not as readable as a filter or "include" type list would be. They have to be filtered one by one, which can be annoying if you only want files -D -S, or only want folders -F -S, or only want symlinks --butwhy?. I considered SyntaxShape::Keyword for this but I'll just defer to comments on this PR if they pop up.

I'd also like to bring up performance since including these flags technically incurs a .filter penalty on all glob calls, which could be optimized out if we added a branch for the no-filters case. But in reality I'd expect the file system to be the bottleneck and the flags to be pretty branch predictor friendly, so eh

User-Facing Changes

Three new flags when using glob and a slightly more cluttered help page. No breaking changes, I hope.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

refactor: use input_handler::operate in ansi_strip command (#7888)

Description

While investigating do --ignore-errors issue, just found that ansi_strip command using a custom operate function(which is not needed), this pr is just a refactor

User-Facing Changes

(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Fix wrong VarId of $in variable (#7893)

Fixes https://github.com/nushell/nushell/issues/7872

Fix panic when assigning value to $env (#7894)

Support extended unicode escapes in strings: "\u{10fff}" (#7883)

Description

Support extended unicode escapes in strings with same syntax as Rust: "\u{6e}".

User-Facing Changes

New syntax in string literals, \u{NNNNNN}, to go along with the existing \uNNNN. New syntax accepts 1-6 hex digits and rejects values greater than 0x10FFFF (max Unicode char)..

(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)

Won't break existing scripts, since this is new syntax.

We might consider deprecating char -u, since users can now embed unicode chars > 0xFFFF with the new escape.

Tests + Formatting

Several unit tests and one integration test added.

  • [x] cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes) Done
  • [x] cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style Done
  • [x] cargo test --workspace to check that all tests pass
    Done

After Submitting

  • [ ] If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Name threads (#7879)

I noticed that it's pretty easy to name threads in Rust. We might as well do this; it's a nice quality of life improvement when you're profiling something and the developers took the time to give threads names.

Also added/cleaned up some comments while I was in the area.

Re-enable some good tests, remove some bad tests (#7875)

I tackled some of the disabled FIXME/#[ignore] tests. Most were straightforward to re-enable, and a few of them did not deserve to be re-enabled.


Co-authored-by: Darren Schroeder 343840+fdncred@users.noreply.github.com

Add Github Actions workflow to check for typos (#7892)

  • Add Github Actions workflow to check typos
  • Fix existing typos

mention do in complete command's doc (#7884)

Description

Closes: #7841

User-Facing Changes

new complete doc:

Complete the external piped in, collecting outputs and exit code

To collect stderr messages and exit_code, external piped in need to wrapped with `do`

Usage:
  > complete

Flags:
  -h, --help - Display the help message for this command

Signatures:
  <any> | complete -> <record>

Examples:
  Run the external completion
  > ^external arg1 | complete

  Run external completion, collects stderr and exit_code
  > do { ^external arg1 } | complete

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.


Co-authored-by: Darren Schroeder 343840+fdncred@users.noreply.github.com

make help commands search term don't generate $nothing (#7896)

Description

Relative: https://github.com/nushell/nushell/pull/7889#issuecomment-1407503567

Make search_terms return empty string rather than nothing, so some other command can handle it better

User-Facing Changes

(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

make parse -r columns return 0-indexed uncapitalised

Created at 1 day ago

attempt to resolve

Created at 1 day ago
pull request opened
prevent `parse_math_expression` from accepting `Operator::Assignment`

Description

Fixes #7872. Prior, = and other assignment operators were allowed in MathExpressions; this was probably in error.

User-Facing Changes

Using "=" in RowConditions and MathExpressions now gives an 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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Created at 1 day ago
create branch
merelymyself create branch test
Created at 1 day ago
issue comment
internal error: missing variable

This also seems to be happening for all other internal variables, eg $env.

If anyone's trying to fix this, maybe take a look at Operator::Assignment: the single "=" sign means eval.rs evaluates this not as a comparison but as assignment and tries to access a var_id that does not exist.

Created at 2 days ago
issue comment
allow `parse` to work better with streams

@fdncred - in this case I think it can't easily be transferred because it's so intrinsically linked to the parse function. However, you're definitely right about how a lot more commands should stream (which currently don't!)

Created at 2 days ago

move redundant code into helper function

Created at 2 days ago

fmt and add test

Created at 2 days ago
issue comment
internal error: missing variable

This seems to be happening for all instances of $in in where.

Created at 2 days ago
pull request opened
allow `parse` to work better with streams

Description

Fixes #7864.

User-Facing Changes

(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Created at 3 days ago

Check all user groups. (#7775)

Previously the group check was only for the current users gid, now we check against all the users groups.

Description

Currently when using the cd command to enter a directory there was only a check against the current user id, and exact current group id, meaning if a directory had a group permission and that group wasn't the users group it was effectively ignored.

The fix simply implements a check through all the users current groups.

Co-authored-by: Darren Schroeder 343840+fdncred@users.noreply.github.com

add magenta to ansi command as synonym for purple (#7785)

Description

Added magenta as a synonym for Purple in the ansi command. Previously, ansi errored out on ansi magenta as the AnsiCode vec didn't have magenta as a name as seen in #7747.

User-Facing Changes

Users can now use the ANSI standard name magenta.

LazyRecord (#7619)

This is an attempt to implement a new Value::LazyRecord variant for performance reasons.

LazyRecord is like a regular Record, but it's possible to access individual columns without evaluating other columns. I've implemented LazyRecord for the special $nu variable; accessing $nu is relatively slow because of all the information in scope, and $nu accounts for about 2/3 of Nu's startup time on Linux.

Benchmarks

I ran some benchmarks on my desktop (Linux, 12900K) and the results are very pleasing.

Nu's time to start up and run a command (cargo build --release; hyperfine 'target/release/nu -c "echo \"Hello, world!\""' --shell=none --warmup 10) goes from 8.8ms to 3.2ms, about 2.8x faster.

Tests are also much faster! Running cargo nextest (with our very slow proptest tests disabled) goes from 7.2s to 4.4s (1.6x faster), because most tests involve launching a new instance of Nu.

Design (updated)

I've added a new LazyRecord trait and added a Value variant wrapping those trait objects, much like CustomValue. LazyRecord implementations must implement these 2 functions:

// All column names
fn column_names(&self) -> Vec<&'static str>;

// Get 1 specific column value
fn get_column_value(&self, column: &str) -> Result<Value, ShellError>;

Serializability

Value variants must implement Serializable and Deserializable, which poses some problems because I want to use unserializable things like EngineState in LazyRecords. To work around this, I basically lie to the type system:

  1. Add #[typetag::serde(tag = "type")] to LazyRecord to make it serializable
  2. Any unserializable fields in LazyRecord implementations get marked with #[serde(skip)]
  3. At the point where a LazyRecord normally would get serialized and sent to a plugin, I instead collect it into a regular Value::Record (which can be serialized)

Add test for fix of issue #7754 (#7756)

Fix already landed with #7779

let find take linebreaks into account in Value::String (#7789)

Description

Fixes #7774. The functionality should be the same as feeding all PipelineDate::Value(Value::String(_,_),_) into lines before putting it into find.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

add dedicated const in pipeline, const builtin var errors (#7784)

Description

Currently let and const share error handling, and this might lead to confusing error messages

sJan17-51

This PR adds dedicated errors to const

str length, str substring, str index-of, split words and split chars now use graphemes instead of UTF-8 bytes (#7752)

Closes https://github.com/nushell/nushell/issues/7742

Do not list deprecated subcommands in help <cmd> (#7798)

Description

BEFORE:

Subcommands:
  str camel-case - Convert a string to camelCase
  str capitalize - Capitalize first letter of text
  str collect - 'str collect' is deprecated. Please use 'str join' instead.
  str contains - Checks if string input contains a substring
  str distance - Compare two strings and return the edit distance/Levenshtein distance
  str downcase - Make text lowercase
  str ends-with - Check if an input ends with a string
  str find-replace - Deprecated command
  str index-of - Returns start index of first occurrence of string in input, or -1 if no match
  str join - Concatenate multiple strings into a single string, with an optional separator between each
  str kebab-case - Convert a string to kebab-case
  str length - Output the length of any strings in the pipeline
  str lpad - Left-pad a string to a specific length
  str pascal-case - Convert a string to PascalCase
  str replace - Find and replace text
  str reverse - Reverse every string in the pipeline
  str rpad - Right-pad a string to a specific length
  str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
  str snake-case - Convert a string to snake_case
  str starts-with - Check if an input starts with a string
  str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
  str title-case - Convert a string to Title Case
  str to-datetime - Deprecated command
  str to-decimal - Deprecated command
  str to-int - Deprecated command
  str trim - Trim whitespace or specific character
  str upcase - Make text uppercase

AFTER:

Subcommands:
  str camel-case - Convert a string to camelCase
  str capitalize - Capitalize first letter of text
  str contains - Checks if string input contains a substring
  str distance - Compare two strings and return the edit distance/Levenshtein distance
  str downcase - Make text lowercase
  str ends-with - Check if an input ends with a string
  str index-of - Returns start index of first occurrence of string in input, or -1 if no match
  str join - Concatenate multiple strings into a single string, with an optional separator between each     
  str kebab-case - Convert a string to kebab-case
  str length - Output the length of any strings in the pipeline
  str lpad - Left-pad a string to a specific length
  str pascal-case - Convert a string to PascalCase
  str replace - Find and replace text
  str reverse - Reverse every string in the pipeline
  str rpad - Right-pad a string to a specific length
  str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
  str snake-case - Convert a string to snake_case
  str starts-with - Check if an input starts with a string
  str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
  str title-case - Convert a string to Title Case
  str trim - Trim whitespace or specific character
  str upcase - Make text uppercase

The deprecated subcommands still exist, but are no longer listed in help for the containing command.

User-Facing Changes

See above.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

fix signature display in help commands (#7802)

Description

This PR fixes the signature display when running help commands. Before this PR, there were leading spaces in the signatures column. Now, they're left aligned for a cleaner look.

Before:

image

After:

image

User-Facing Changes

(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

fetch -> http get and post -> http post (#7796)

Updated description by @rgwood

This PR changes fetch to http get and post to http post. fetch and post are now deprecated. I surveyed people on Discord and users strongly approved of this change.

Original Description

This PR is related to #2741 and my first pull request in rust :)

Implemented a new http mod to better http support and alias fetch and post commands to http get and http post respectively.

User-Facing Changes

Users will be able to use HTTP method via http command, for example

> http get "https://www.example.com"
<!doctype html>
<html>
...

Cleanup of src/main.rs (#7801)

While reading nushell's code, I've started to clean up src/main.rs a bit. The description of the changes can be found in the commit messages.

Move all functions of main.rs into modules (#7803)

The affected modules are:

  • command.rs
  • config_files.rs
  • terminal.rs

Clean up nu-cli/src/eval_file.rs (#7804)

  • Replace match with unwrap_or_else or if let
  • Remove unnecessary mut
  • Check if file path has a parent
  • Reduce visibility to pub(crate)

nu-table: Wrap last column in table -e (#7778)

Hi @rgwood thank you for report.

So this PR must fix it but I'd make a few runs.

close #7763

Signed-off-by: Maxim Zhiburt zhiburt@gmail.com

Bump libgit2-sys from 0.14.1+1.5.0 to 0.14.2+1.5.1 (#7806)

Bump git2 from 0.16.0 to 0.16.1 (#7807)

Bump bumpalo from 3.11.0 to 3.12.0 (#7805)

Extract manual PWD extraction with method current_work_dir (#7812)

Reduce number of match calls (#7813)

[nu-test-support] Gate system locale tests (#7824)

Description

src/locale_override.rs is gated with #![cfg(debug_assertions)] but tests/get_system_locale.rs is not; this makes cargo test --release fails:

error[E0432]: unresolved import `nu_test_support::locale_override`
 --> crates/nu-test-support/tests/get_system_locale.rs:1:22
  |
1 | use nu_test_support::locale_override::with_locale_override;
  |                      ^^^^^^^^^^^^^^^ could not find `locale_override` in `nu_test_support`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `nu-test-support` due to previous error
warning: build failed, waiting for other jobs to finish...

With the change it now passes:

❯ cargo test --release
   Compiling nu-test-support v0.74.1 (/home/michel/src/github/nushell/nushell/crates/nu-test-support)
    Finished release [optimized] target(s) in 7.57s
     Running unittests src/lib.rs (/home/michel/src/github/nushell/nushell/target/release/deps/nu_test_support-750505b13c102d2c)

running 3 tests
test tests::constructs_a_pipeline ... ok
test playground::tests::current_working_directory_back_to_root_from_anywhere ... ok
test playground::tests::current_working_directory_in_sandbox_directory_created ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/get_system_locale.rs (/home/michel/src/github/nushell/nushell/target/release/deps/get_system_locale-e0ecabe312044fa8)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org

User-Facing Changes

N/A

Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org

Created at 3 days ago

Date is: Tue Jan 24 04:50:05 PM +08 2023

Created at 5 days ago
pull request opened
Sync history on exit

Description

Attempts to act as a partial solution for #7790. It works by moving the handling of exit from within the run itself to the repl. (This only happens if the exit does not happen through a nushell sub-shell.)

User-Facing Changes

(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Created at 6 days ago

Bump git2 from 0.16.0 to 0.16.1 (#7807)

Bump bumpalo from 3.11.0 to 3.12.0 (#7805)

Extract manual PWD extraction with method current_work_dir (#7812)

Reduce number of match calls (#7813)

[nu-test-support] Gate system locale tests (#7824)

Description

src/locale_override.rs is gated with #![cfg(debug_assertions)] but tests/get_system_locale.rs is not; this makes cargo test --release fails:

error[E0432]: unresolved import `nu_test_support::locale_override`
 --> crates/nu-test-support/tests/get_system_locale.rs:1:22
  |
1 | use nu_test_support::locale_override::with_locale_override;
  |                      ^^^^^^^^^^^^^^^ could not find `locale_override` in `nu_test_support`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `nu-test-support` due to previous error
warning: build failed, waiting for other jobs to finish...

With the change it now passes:

❯ cargo test --release
   Compiling nu-test-support v0.74.1 (/home/michel/src/github/nushell/nushell/crates/nu-test-support)
    Finished release [optimized] target(s) in 7.57s
     Running unittests src/lib.rs (/home/michel/src/github/nushell/nushell/target/release/deps/nu_test_support-750505b13c102d2c)

running 3 tests
test tests::constructs_a_pipeline ... ok
test playground::tests::current_working_directory_back_to_root_from_anywhere ... ok
test playground::tests::current_working_directory_in_sandbox_directory_created ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/get_system_locale.rs (/home/michel/src/github/nushell/nushell/target/release/deps/get_system_locale-e0ecabe312044fa8)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org

User-Facing Changes

N/A

Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org

Fix typos (#7811)

Some minor text fixes

Fix multi-line redirection inside a block (#7808)

Description

Fixes: #7786

The issue is because the lite block is wrong while converting from lex tokens

What happened internally?

Take the following as example:

❯ def foobar [] { 
    'hello' out> /tmp/output.1
    'world' out> /tmp/output.2
}

Before:

LiteBlock { block: [
    LitePipeline { commands: [
        Command(None, LiteCommand { comments: [], parts: [Span { start: 40900, end:40907 }] }),
        Redirection(Span { start: 40908, end: 40912 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40913, end: 40926 }] })]
    },
    LitePipeline { commands: [
        Redirection(Span { start: 40908, end: 40912 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40929, end: 40936 }] }),   // this is wrong, should be command.
        Redirection(Span { start: 40937, end: 40941 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40942, end: 40955 }] })]
    }] }

After:

LiteBlock { block: [
    LitePipeline { commands: [
        Command(None, LiteCommand { comments: [], parts: [Span { start: 40824, end: 40831 }] }),
        Redirection(Span { start: 40832, end: 40836 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40837, end: 40850 }] })] 
    },
    LitePipeline { commands: [
        Command(None, LiteCommand { comments: [], parts: [Span { start: 40854, end: 40861 }] }), 
        Redirection(Span { start: 40862, end: 40866 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40867, end: 40880 }] })] 
    }
] }

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

benchmark now pipes input into the closure (#7776)

Description

Closes #7762. See issue for motivation.

User-Facing Changes

Something like this is now possible without having to split this into 2 commands:

fetch "https://www.gutenberg.org/files/11/11-0.txt" | benchmark { str downcase | split words | uniq -c | sort-by count --reverse | first 10 }

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Co-authored-by: Stefan Holderbach sholderbach@users.noreply.github.com

Feat/7725 url join (#7823)

Description

Added command: url join. Closes: #7725

User-Facing Changes

Converts a record to url

Search terms: scheme, username, password, hostname, port, path, query, fragment

Usage:
  > url join

Flags:
  -h, --help - Display the help message for this command

Signatures:
  <record> | url join -> <string>

Examples:
  Outputs a url representing the contents of this record
  > {
          "scheme": "http",
          "username": "",
          "password": "",
          "host": "www.pixiv.net",
          "port": "",
          "path": "/member_illust.php",
          "query": "mode=medium&illust_id=99260204",
          "fragment": "",
          "params":
          {
            "mode": "medium",
            "illust_id": "99260204"
          }
        } | url join

  Outputs a url representing the contents of this record
  > {
        "scheme": "http",
        "username": "user",
        "password": "pwd",
        "host": "www.pixiv.net",
        "port": "1234",
        "query": "test=a",
        "fragment": ""
      } | url join

  Outputs a url representing the contents of this record
  > {
        "scheme": "http",
        "host": "www.pixiv.net",
        "port": "1234",
        "path": "user",
        "fragment": "frag"
      } | url join

Questions

  • Which parameters should be required? Currenlty are: scheme and host.

Allow main command to define top-level module command (#7764)

Fix command name lookup for known externals (#7830)

Fixes https://github.com/nushell/nushell/issues/7822

Bump regex from 1.6.0 to 1.7.1 (#7833)

Bump scraper from 0.13.0 to 0.14.0 (#7835)

Bump shadow-rs from 0.16.3 to 0.20.0 (#7837)

Bump miette from 5.3.0 to 5.5.0 (#7838)

Bump sysinfo from 0.26.4 to 0.27.7 (#7839)

Bump actions-rust-lang/setup-rust-toolchain from 1.3.4 to 1.3.5 (#7840)

Bumps actions-rust-lang/setup-rust-toolchain from 1.3.4 to 1.3.5.

Dependabot compatibility
score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Bump rayon from 1.5.3 to 1.6.1 (#7836)

Bumps rayon from 1.5.3 to 1.6.1.

Dependabot compatibility
score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

print nushell startup time (#7831)

Description

This PR shows the startup time and decreases the banner. This startup time output can be disabled with the show_banner: false setting in the config. This is the startup in debug mode.

image

On my mac in release mode

Startup Time: 368ms 429µs 83ns

On my mac without a config as nu --config foo --env-config foo

Startup Time: 11ms 663µs 791ns

I could really go either way on this. If people don't like this change, we don't have to merge it.

User-Facing Changes

Startup Time

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

sync history on exit

Created at 6 days ago
pull request closed
Allow for multiline commands in scripts by escaping newlines with '\'

Description

Fixes #7780 (?)

The functionality is borrowed from bash, but I don't have strong feelings about it. My main concern is that the substitution for the escape happens at the wrong time, which could be problematic for future maintainers.

As seen in the example,

echo "longarg" \
"longarg2"

is parsed as

echo "longarg" "longarg2"

Same can be done for flags, for instance

ls --all \
--du

Should work properly.

User-Facing Changes

A backslash followed by a newline now escapes the newline.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Created at 1 week ago
issue comment
Allow for multiline commands in scripts by escaping newlines with '\'

Ok, thanks! I'll close this for the moment until a decision is made.

Created at 1 week ago

simplify test

Created at 1 week ago
pull request opened
Allow for multiline commands in scripts by escaping newlines with '\'

Description

Fixes #7780 (?)

The functionality is borrowed from bash, but I don't have strong feelings about it. My main concern is that the substitution for the escape happens at the wrong time, which could be problematic for future maintainers.

User-Facing Changes

A backslash followed by a newline now escapes the newline.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

Created at 1 week ago

LazyRecord (#7619)

This is an attempt to implement a new Value::LazyRecord variant for performance reasons.

LazyRecord is like a regular Record, but it's possible to access individual columns without evaluating other columns. I've implemented LazyRecord for the special $nu variable; accessing $nu is relatively slow because of all the information in scope, and $nu accounts for about 2/3 of Nu's startup time on Linux.

Benchmarks

I ran some benchmarks on my desktop (Linux, 12900K) and the results are very pleasing.

Nu's time to start up and run a command (cargo build --release; hyperfine 'target/release/nu -c "echo \"Hello, world!\""' --shell=none --warmup 10) goes from 8.8ms to 3.2ms, about 2.8x faster.

Tests are also much faster! Running cargo nextest (with our very slow proptest tests disabled) goes from 7.2s to 4.4s (1.6x faster), because most tests involve launching a new instance of Nu.

Design (updated)

I've added a new LazyRecord trait and added a Value variant wrapping those trait objects, much like CustomValue. LazyRecord implementations must implement these 2 functions:

// All column names
fn column_names(&self) -> Vec<&'static str>;

// Get 1 specific column value
fn get_column_value(&self, column: &str) -> Result<Value, ShellError>;

Serializability

Value variants must implement Serializable and Deserializable, which poses some problems because I want to use unserializable things like EngineState in LazyRecords. To work around this, I basically lie to the type system:

  1. Add #[typetag::serde(tag = "type")] to LazyRecord to make it serializable
  2. Any unserializable fields in LazyRecord implementations get marked with #[serde(skip)]
  3. At the point where a LazyRecord normally would get serialized and sent to a plugin, I instead collect it into a regular Value::Record (which can be serialized)

Add test for fix of issue #7754 (#7756)

Fix already landed with #7779

let find take linebreaks into account in Value::String (#7789)

Description

Fixes #7774. The functionality should be the same as feeding all PipelineDate::Value(Value::String(_,_),_) into lines before putting it into find.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

add dedicated const in pipeline, const builtin var errors (#7784)

Description

Currently let and const share error handling, and this might lead to confusing error messages

sJan17-51

This PR adds dedicated errors to const

str length, str substring, str index-of, split words and split chars now use graphemes instead of UTF-8 bytes (#7752)

Closes https://github.com/nushell/nushell/issues/7742

Do not list deprecated subcommands in help <cmd> (#7798)

Description

BEFORE:

Subcommands:
  str camel-case - Convert a string to camelCase
  str capitalize - Capitalize first letter of text
  str collect - 'str collect' is deprecated. Please use 'str join' instead.
  str contains - Checks if string input contains a substring
  str distance - Compare two strings and return the edit distance/Levenshtein distance
  str downcase - Make text lowercase
  str ends-with - Check if an input ends with a string
  str find-replace - Deprecated command
  str index-of - Returns start index of first occurrence of string in input, or -1 if no match
  str join - Concatenate multiple strings into a single string, with an optional separator between each
  str kebab-case - Convert a string to kebab-case
  str length - Output the length of any strings in the pipeline
  str lpad - Left-pad a string to a specific length
  str pascal-case - Convert a string to PascalCase
  str replace - Find and replace text
  str reverse - Reverse every string in the pipeline
  str rpad - Right-pad a string to a specific length
  str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
  str snake-case - Convert a string to snake_case
  str starts-with - Check if an input starts with a string
  str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
  str title-case - Convert a string to Title Case
  str to-datetime - Deprecated command
  str to-decimal - Deprecated command
  str to-int - Deprecated command
  str trim - Trim whitespace or specific character
  str upcase - Make text uppercase

AFTER:

Subcommands:
  str camel-case - Convert a string to camelCase
  str capitalize - Capitalize first letter of text
  str contains - Checks if string input contains a substring
  str distance - Compare two strings and return the edit distance/Levenshtein distance
  str downcase - Make text lowercase
  str ends-with - Check if an input ends with a string
  str index-of - Returns start index of first occurrence of string in input, or -1 if no match
  str join - Concatenate multiple strings into a single string, with an optional separator between each     
  str kebab-case - Convert a string to kebab-case
  str length - Output the length of any strings in the pipeline
  str lpad - Left-pad a string to a specific length
  str pascal-case - Convert a string to PascalCase
  str replace - Find and replace text
  str reverse - Reverse every string in the pipeline
  str rpad - Right-pad a string to a specific length
  str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
  str snake-case - Convert a string to snake_case
  str starts-with - Check if an input starts with a string
  str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
  str title-case - Convert a string to Title Case
  str trim - Trim whitespace or specific character
  str upcase - Make text uppercase

The deprecated subcommands still exist, but are no longer listed in help for the containing command.

User-Facing Changes

See above.

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

fix signature display in help commands (#7802)

Description

This PR fixes the signature display when running help commands. Before this PR, there were leading spaces in the signatures column. Now, they're left aligned for a cleaner look.

Before:

image

After:

image

User-Facing Changes

(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

fetch -> http get and post -> http post (#7796)

Updated description by @rgwood

This PR changes fetch to http get and post to http post. fetch and post are now deprecated. I surveyed people on Discord and users strongly approved of this change.

Original Description

This PR is related to #2741 and my first pull request in rust :)

Implemented a new http mod to better http support and alias fetch and post commands to http get and http post respectively.

User-Facing Changes

Users will be able to use HTTP method via http command, for example

> http get "https://www.example.com"
<!doctype html>
<html>
...

Cleanup of src/main.rs (#7801)

While reading nushell's code, I've started to clean up src/main.rs a bit. The description of the changes can be found in the commit messages.

Move all functions of main.rs into modules (#7803)

The affected modules are:

  • command.rs
  • config_files.rs
  • terminal.rs

Clean up nu-cli/src/eval_file.rs (#7804)

  • Replace match with unwrap_or_else or if let
  • Remove unnecessary mut
  • Check if file path has a parent
  • Reduce visibility to pub(crate)

nu-table: Wrap last column in table -e (#7778)

Hi @rgwood thank you for report.

So this PR must fix it but I'd make a few runs.

close #7763

Signed-off-by: Maxim Zhiburt zhiburt@gmail.com

Bump libgit2-sys from 0.14.1+1.5.0 to 0.14.2+1.5.1 (#7806)

files can multiline commands

add test and fix functionality

Created at 1 week ago