Skip to content

Commit

Permalink
Add release note for changes to parse (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanManske committed May 30, 2024
1 parent de9c1eb commit 9281317
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions blog/2024-05-28-nushell_0_94_0.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The `dataframes` cargo feature [has been removed in this release](#removal-of-de
- [_`debug profile --lines`_](#debug-profile-lines-toc)
- [_Changes to existing commands_](#changes-to-existing-commands-toc)
- [_Making range semantics consistent_](#making-range-semantics-consistent-toc)
- [_`parse`_](#parse-toc)
- [_`scope commands`_](#scope-commands-toc)
- [_`which`_](#which-toc)
- [_`describe`_](#describe-toc)
Expand Down Expand Up @@ -255,6 +256,38 @@ Ranges are inclusive in the upper bound by default in Nushell (e.g., `1..2` or `

To specify an exclusive upperbound, use the `..<` form for ranges (e.g., `1..<2`).

#### `parse` [[toc](#table-of-content)]

::: warning Breaking change
See a full overview of the [breaking changes](#breaking-changes)
:::

To support streaming output, `parse` now operates/matches on a single line at a time **only if provided with the streaming output of an external command, file, or raw byte stream**.
For example, these snippets will try to match each line separately:
```nushell
^cat file.txt | parse -r "some regex"
^cat file.txt | take 1024 | parse -r "some regex"
open file.txt | parse -r "some regex"
open --raw file.txt | parse -r "some regex"
open --raw file.txt | skip 1024 | parse -r "some regex"
```

The old behavior was to collect all of the output the external command or byte stream and then run the regex across the whole string. To mimic this behavior, you can use the `collect` command or store the output in a variable:
```nushell
^cat file.txt | collect | parse -r "some regex"
let text = open file.txt
$text | parse -r "some regex"
```

Note that this change does not affect normal value streams like
```nushell
[(open foo.txt) (open bar.txt)] | parse -r "..."
```
In this case, the regex is run once per string value in the stream and does a multi-line match over the contents of each string.

Note that `parse` may see more breaking changes in the next release to simplify this behavior.

#### `scope commands` [[toc](#table-of-content)]

::: warning Breaking change
Expand Down

0 comments on commit 9281317

Please sign in to comment.