mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 03:44:19 +01:00
std: add cross platform null-device name (#11070)
# Description We have meet a discord discussion about cross platform `null-device`: https://discord.com/channels/601130461678272522/988303282931912704/1165966467095875624 I want the same feature too...And I think it's good enough to add it into `nu-std`. Different to https://github.com/nushell/nu_scripts/pull/649/files, I think named it to `null-device`(the name comes from [wiki](https://en.wikipedia.org/wiki/Null_device)) is better than `null-stream`.
This commit is contained in:
parent
d1137cc700
commit
5063e01c12
@ -335,3 +335,16 @@ export def repeat [
|
|||||||
|
|
||||||
1..$n | each { $item }
|
1..$n | each { $item }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user