with-env

For env.

Runs a block with an environment variable set.

Command Type

built-in

Signature

> with-env {flags} (variable) (block)

Parameters

  • variable: The environment variable to temporarily set.
  • block: The block to run once the variable is set.

Input/output types:

input output
any any

Examples

Set by key-value record.

> with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
╭───┬───╮
│ 0 │ Y │
│ 1 │ Z │
╰───┴───╯

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.