summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJT <547158+jntrnr@users.noreply.github.com>2023-03-22 10:32:43 +1300
committerGitHub <noreply@github.com>2023-03-21 14:32:43 -0700
commit7ff4eb10c7eabdfe82c6de1ef5796f2c0da39c7b (patch)
tree8931bdc2fa049ef3b3cdc5a228d0e1c03a19a5cb
parenta91a75b9857542d8659d5bdd8e84e3723f9d0451 (diff)
downloadvirtualenv-7ff4eb10c7eabdfe82c6de1ef5796f2c0da39c7b.tar.gz
Update Nushell 'let' syntax (#2527)
-rw-r--r--docs/changelog/2527.bugfix.rst2
-rw-r--r--src/virtualenv/activation/nushell/activate.nu22
2 files changed, 13 insertions, 11 deletions
diff --git a/docs/changelog/2527.bugfix.rst b/docs/changelog/2527.bugfix.rst
new file mode 100644
index 0000000..ff5800f
--- /dev/null
+++ b/docs/changelog/2527.bugfix.rst
@@ -0,0 +1,2 @@
+Move the use of 'let' in nushell to ensure compatibility with future releases of nushell, where 'let' no longer
+assumes that its initializer is a full expressions.
diff --git a/src/virtualenv/activation/nushell/activate.nu b/src/virtualenv/activation/nushell/activate.nu
index e475623..69755e6 100644
--- a/src/virtualenv/activation/nushell/activate.nu
+++ b/src/virtualenv/activation/nushell/activate.nu
@@ -19,7 +19,7 @@ export-env {
def is-env-true [name: string] {
if (has-env $name) {
# Try to parse 'true', '0', '1', and fail if not convertible
- let parsed = do -i { $env | get $name | into bool }
+ let parsed = (do -i { $env | get $name | into bool })
if ($parsed | describe) == 'bool' {
$parsed
} else {
@@ -34,7 +34,7 @@ export-env {
let virtual_env = '__VIRTUAL_ENV__'
let bin = '__BIN_NAME__'
let path_sep = (char esep)
- let path_name = if $is_windows {
+ let path_name = (if $is_windows {
if (has-env 'Path') {
'Path'
} else {
@@ -42,7 +42,7 @@ export-env {
}
} else {
'PATH'
- }
+ })
let old_path = (
if $is_windows {
@@ -69,18 +69,18 @@ export-env {
VIRTUAL_ENV : $virtual_env
}
- let new_env = if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') {
+ let new_env = (if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') {
$new_env
} else {
# Creating the new prompt for the session
- let virtual_prompt = if ('__VIRTUAL_PROMPT__' == '') {
+ let virtual_prompt = (if ('__VIRTUAL_PROMPT__' == '') {
$'(char lparen)($virtual_env | path basename)(char rparen) '
} else {
'(__VIRTUAL_PROMPT__) '
- }
+ })
# Back up the old prompt builder
- let old_prompt_command = if (has-env 'VIRTUAL_ENV') and (has-env '_OLD_PROMPT_COMMAND') {
+ let old_prompt_command = (if (has-env 'VIRTUAL_ENV') and (has-env '_OLD_PROMPT_COMMAND') {
$env._OLD_PROMPT_COMMAND
} else {
if (has-env 'PROMPT_COMMAND') {
@@ -88,10 +88,10 @@ export-env {
} else {
''
}
- }
+ })
# If there is no default prompt, then only the env is printed in the prompt
- let new_prompt = if (has-env 'PROMPT_COMMAND') {
+ let new_prompt = (if (has-env 'PROMPT_COMMAND') {
if 'closure' in ($old_prompt_command | describe) {
{|| $'($virtual_prompt)(do $old_prompt_command)' }
} else {
@@ -99,7 +99,7 @@ export-env {
}
} else {
{|| $'($virtual_prompt)' }
- }
+ })
$new_env | merge {
_OLD_VIRTUAL_PATH : ($old_path | str collect $path_sep)
@@ -107,7 +107,7 @@ export-env {
PROMPT_COMMAND : $new_prompt
VIRTUAL_PROMPT : $virtual_prompt
}
- }
+ })
# Environment variables that will be loaded as the virtual env
load-env $new_env