small, backwards compatible enhancements to std (#14763)

# Description
Small, backwards compatible enhancements to the standard library.

# User-Facing Changes

- changed `iter find`, `iter find-index`: Only consume the input stream
up to the first match.
- added `log set-level`: a small convenience command for setting the log
level
- added `$null_device`: `null-device` as a const variable, would allow
conditional sourcing if #13872 is fixed

# Tests + Formatting

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

# After Submitting
N/A
This commit is contained in:
Bahex
2025-01-06 20:30:07 +03:00
committed by GitHub
parent b60f91f722
commit ebabca575c
4 changed files with 44 additions and 51 deletions

View File

@ -110,15 +110,18 @@ export def repeat [
1..$n | each { $item }
}
# null device file
export const null_device = if $nu.os-info.name == "windows" {
'\\.\NUL'
} else {
'/dev/null'
}
# return a null device file.
#
# # Examples
# run a command and ignore it's stderr output
# > cat xxx.txt e> (null-device)
export def null-device []: nothing -> path {
if ($nu.os-info.name | str downcase) == "windows" {
'\\.\NUL'
} else {
"/dev/null"
}
$null_device
}