mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 14:41:00 +02:00
Move $nu.env to $env (#665)
* Move env from nu builtin to its own * update samples/tests
This commit is contained in:
@ -39,7 +39,7 @@ You can test the conversions by manually calling them:
|
||||
```
|
||||
> let-env FOO = "a:b:c"
|
||||
|
||||
> let list = (do $config.env_conversions.from_string $nu.env.FOO)
|
||||
> let list = (do $config.env_conversions.from_string $env.FOO)
|
||||
|
||||
> $list
|
||||
╭───┬───╮
|
||||
@ -58,7 +58,7 @@ To verify the conversion works on startup, you can first set up `FOO`, then laun
|
||||
|
||||
> nu
|
||||
|
||||
>> $nu.env.FOO
|
||||
>> $env.FOO
|
||||
╭───┬───╮
|
||||
│ 0 │ a │
|
||||
│ 1 │ b │
|
||||
@ -94,8 +94,8 @@ Out of the box, Nushell ships with several environment variables serving a speci
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
* Setting environment variable to `$nothing` will no longer remove it -- it will be `$nothing`. Instead, you can use `hide $nu.env.FOO`.
|
||||
* `$nu.env.PROMPT_COMMAND` is a block instead of a string containing the source of the command to run. You can put this into your `config.nu`, for example: `let-env PROMPT_COMMAND = { echo "foo" }`.
|
||||
* Setting environment variable to `$nothing` will no longer remove it -- it will be `$nothing`. Instead, you can use `hide $env.FOO`.
|
||||
* `$env.PROMPT_COMMAND` is a block instead of a string containing the source of the command to run. You can put this into your `config.nu`, for example: `let-env PROMPT_COMMAND = { echo "foo" }`.
|
||||
|
||||
## Future Directions
|
||||
|
||||
|
@ -163,10 +163,10 @@ export def hello [name: string] {
|
||||
```
|
||||
> use greetings.nu
|
||||
|
||||
> $nu.env."greetings MYNAME"
|
||||
> $env."greetings MYNAME"
|
||||
Arthur, King of the Britons
|
||||
|
||||
> greetings hello $nu.env."greetings MYNAME"
|
||||
> greetings hello $env."greetings MYNAME"
|
||||
hello Arthur, King of the Britons!
|
||||
```
|
||||
|
||||
@ -178,18 +178,18 @@ We can demonstrate this property for example with the `random` command:
|
||||
|
||||
> use roll ROLL
|
||||
|
||||
> $nu.env.ROLL
|
||||
> $env.ROLL
|
||||
4
|
||||
|
||||
> $nu.env.ROLL
|
||||
> $env.ROLL
|
||||
4
|
||||
|
||||
> use roll ROLL
|
||||
|
||||
> $nu.env.ROLL
|
||||
> $env.ROLL
|
||||
6
|
||||
|
||||
> $nu.env.ROLL
|
||||
> $env.ROLL
|
||||
6
|
||||
```
|
||||
|
||||
@ -227,18 +227,18 @@ Let's try environment variables:
|
||||
```
|
||||
> let-env FOO = "FOO"
|
||||
|
||||
> $nu.env.FOO
|
||||
> $env.FOO
|
||||
FOO
|
||||
|
||||
> hide FOO
|
||||
|
||||
> $nu.env.FOO # error! environment variable not found!
|
||||
> $env.FOO # error! environment variable not found!
|
||||
```
|
||||
The first case also applies to commands / environment variables brought from a module (using the "greetings.nu" file defined above):
|
||||
```
|
||||
> use greetings.nu *
|
||||
|
||||
> $nu.env.MYNAME
|
||||
> $env.MYNAME
|
||||
Arthur, King of the Britons
|
||||
|
||||
> hello "world"
|
||||
@ -246,7 +246,7 @@ hello world!
|
||||
|
||||
> hide MYNAME
|
||||
|
||||
> $nu.env.MYNAME # error! environment variable not found!
|
||||
> $env.MYNAME # error! environment variable not found!
|
||||
|
||||
> hide hello
|
||||
|
||||
@ -256,7 +256,7 @@ And finally, when the name is the module name (assuming the previous `greetings`
|
||||
```
|
||||
> use greetings.nu
|
||||
|
||||
> $nu.env."greetings MYNAME"
|
||||
> $env."greetings MYNAME"
|
||||
Arthur, King of the Britons
|
||||
|
||||
> greetings hello "world"
|
||||
@ -264,7 +264,7 @@ hello world!
|
||||
|
||||
> hide greetings
|
||||
|
||||
> $nu.env."greetings MYNAME" # error! environment variable not found!
|
||||
> $env."greetings MYNAME" # error! environment variable not found!
|
||||
|
||||
> greetings hello "world" # error! command not found!
|
||||
```
|
||||
@ -275,7 +275,7 @@ To demonstrate the other cases (again, assuming the same `greetings` module):
|
||||
|
||||
> hide greetings hello
|
||||
|
||||
> $nu.env."greetings MYNAME"
|
||||
> $env."greetings MYNAME"
|
||||
Arthur, King of the Britons
|
||||
|
||||
> greetings hello "world" # error! command not found!
|
||||
@ -285,7 +285,7 @@ Arthur, King of the Britons
|
||||
|
||||
> hide greetings [ hello MYNAME ]
|
||||
|
||||
> $nu.env."greetings MYNAME" # error! environment variable not found!
|
||||
> $env."greetings MYNAME" # error! environment variable not found!
|
||||
|
||||
> greetings hello "world" # error! command not found!
|
||||
```
|
||||
@ -294,7 +294,7 @@ Arthur, King of the Britons
|
||||
|
||||
> hide greetings *
|
||||
|
||||
> $nu.env."greetings MYNAME" # error! environment variable not found!
|
||||
> $env."greetings MYNAME" # error! environment variable not found!
|
||||
|
||||
> greetings hello "world" # error! command not found!
|
||||
```
|
||||
|
Reference in New Issue
Block a user