mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
Fix def-env
docs according to docs#761 (#7972)
See nushell/nushell.github.io#761 # User-Facing Changes Docs reflect up-to-date reality Co-authored-by: Canop <cano.petrole@gmail.com>
This commit is contained in:
parent
d50eb9b41b
commit
4c308b7f2f
1 changed files with 1 additions and 26 deletions
|
@ -28,32 +28,7 @@ impl Command for DefEnv {
|
||||||
fn extra_usage(&self) -> &str {
|
fn extra_usage(&self) -> &str {
|
||||||
r#"This command is a parser keyword. For details, check:
|
r#"This command is a parser keyword. For details, check:
|
||||||
https://www.nushell.sh/book/thinking_in_nu.html
|
https://www.nushell.sh/book/thinking_in_nu.html
|
||||||
|
"#
|
||||||
=== EXTRA NOTE ===
|
|
||||||
All blocks are scoped, including variable definition and environment variable changes.
|
|
||||||
|
|
||||||
Because of this, the following doesn't work:
|
|
||||||
|
|
||||||
def-env cd_with_fallback [arg = ""] {
|
|
||||||
let fall_back_path = "/tmp"
|
|
||||||
if $arg != "" {
|
|
||||||
cd $arg
|
|
||||||
} else {
|
|
||||||
cd $fall_back_path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Instead, you have to use cd in the top level scope:
|
|
||||||
|
|
||||||
def-env cd_with_fallback [arg = ""] {
|
|
||||||
let fall_back_path = "/tmp"
|
|
||||||
let path = if $arg != "" {
|
|
||||||
$arg
|
|
||||||
} else {
|
|
||||||
$fall_back_path
|
|
||||||
}
|
|
||||||
cd $path
|
|
||||||
}"#
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_parser_keyword(&self) -> bool {
|
fn is_parser_keyword(&self) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue