Skip to content

Commit 7ff4eb1

Browse files
authored
Update Nushell 'let' syntax (#2527)
1 parent a91a75b commit 7ff4eb1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

docs/changelog/2527.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Move the use of 'let' in nushell to ensure compatibility with future releases of nushell, where 'let' no longer
2+
assumes that its initializer is a full expressions.

src/virtualenv/activation/nushell/activate.nu

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export-env {
1919
def is-env-true [name: string] {
2020
if (has-env $name) {
2121
# Try to parse 'true', '0', '1', and fail if not convertible
22-
let parsed = do -i { $env | get $name | into bool }
22+
let parsed = (do -i { $env | get $name | into bool })
2323
if ($parsed | describe) == 'bool' {
2424
$parsed
2525
} else {
@@ -34,15 +34,15 @@ export-env {
3434
let virtual_env = '__VIRTUAL_ENV__'
3535
let bin = '__BIN_NAME__'
3636
let path_sep = (char esep)
37-
let path_name = if $is_windows {
37+
let path_name = (if $is_windows {
3838
if (has-env 'Path') {
3939
'Path'
4040
} else {
4141
'PATH'
4242
}
4343
} else {
4444
'PATH'
45-
}
45+
})
4646

4747
let old_path = (
4848
if $is_windows {
@@ -69,45 +69,45 @@ export-env {
6969
VIRTUAL_ENV : $virtual_env
7070
}
7171

72-
let new_env = if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') {
72+
let new_env = (if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') {
7373
$new_env
7474
} else {
7575
# Creating the new prompt for the session
76-
let virtual_prompt = if ('__VIRTUAL_PROMPT__' == '') {
76+
let virtual_prompt = (if ('__VIRTUAL_PROMPT__' == '') {
7777
$'(char lparen)($virtual_env | path basename)(char rparen) '
7878
} else {
7979
'(__VIRTUAL_PROMPT__) '
80-
}
80+
})
8181

8282
# Back up the old prompt builder
83-
let old_prompt_command = if (has-env 'VIRTUAL_ENV') and (has-env '_OLD_PROMPT_COMMAND') {
83+
let old_prompt_command = (if (has-env 'VIRTUAL_ENV') and (has-env '_OLD_PROMPT_COMMAND') {
8484
$env._OLD_PROMPT_COMMAND
8585
} else {
8686
if (has-env 'PROMPT_COMMAND') {
8787
$env.PROMPT_COMMAND
8888
} else {
8989
''
9090
}
91-
}
91+
})
9292

9393
# If there is no default prompt, then only the env is printed in the prompt
94-
let new_prompt = if (has-env 'PROMPT_COMMAND') {
94+
let new_prompt = (if (has-env 'PROMPT_COMMAND') {
9595
if 'closure' in ($old_prompt_command | describe) {
9696
{|| $'($virtual_prompt)(do $old_prompt_command)' }
9797
} else {
9898
{|| $'($virtual_prompt)($old_prompt_command)' }
9999
}
100100
} else {
101101
{|| $'($virtual_prompt)' }
102-
}
102+
})
103103

104104
$new_env | merge {
105105
_OLD_VIRTUAL_PATH : ($old_path | str collect $path_sep)
106106
_OLD_PROMPT_COMMAND : $old_prompt_command
107107
PROMPT_COMMAND : $new_prompt
108108
VIRTUAL_PROMPT : $virtual_prompt
109109
}
110-
}
110+
})
111111

112112
# Environment variables that will be loaded as the virtual env
113113
load-env $new_env

0 commit comments

Comments
 (0)