Skip to content

Commit 0a653a5

Browse files
committed
Stefan's env tweaks
1 parent be449ce commit 0a653a5

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

blog/2024-04-30-nushell_0_93_0.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,32 @@ Thanks to all the contributors below for helping us making the documentation of
103103
See a full overview of the [breaking changes](#breaking-changes-toc)
104104
:::
105105

106-
The environment variable list form of `with-env` is now deprecated aftter [#12523](https://github.com/nushell/nushell/pull/12523):
106+
Passing environment variables to `with-env` via the list-like or single-row table form is now deprecated after
107+
[#12523](https://github.com/nushell/nushell/pull/12523):
108+
107109
```nushell
110+
# deprecated
108111
with-env [X Y W Z] { $env.X }
112+
# also deprecated
113+
with-env [[X Y]; [W Z]] { $env.X }
109114
```
110115

111-
Instead, one should use the record form:
116+
Instead, you should use the record form:
117+
112118
```nushell
113119
with-env { X: 'Y', W: 'Z' } { $env.X }
114120
```
115121

122+
This also explicitly stops you from repeating the name of a environment variable, which was a potential source of
123+
bugs.
124+
125+
```nushell
126+
# silently: bar
127+
with-env [X foo X bar] { $env.X }
128+
# error
129+
with-env { X: 'foo', X: 'bar' } { $env.X }
130+
```
131+
116132
Additionally, setting the `PWD` variable through `with-env` is now disallowed.
117133

118134
#### `load-env` [[toc](#table-of-content)]
@@ -121,8 +137,7 @@ Additionally, setting the `PWD` variable through `with-env` is now disallowed.
121137
See a full overview of the [breaking changes](#breaking-changes-toc)
122138
:::
123139

124-
With [#12522](https://github.com/nushell/nushell/pull/12522), setting the `PWD` variable through `load-env` is now disallowed.
125-
140+
With [#12522](https://github.com/nushell/nushell/pull/12522), setting the `PWD` variable through `load-env` is now disallowed, both when the record is given as a pipeline input or command argument.
126141

127142
#### `last` [[toc](#table-of-content)]
128143

0 commit comments

Comments
 (0)