nushell/crates/nu-std/std
Stefan Holderbach c9e9b138eb
Improve with-env robustness (#12523)
# Description
Work for #7149

- **Error `with-env` given uneven count in list form**
- **Fix `with-env` `CantConvert` to record**
- **Error `with-env` when given protected env vars**
- **Deprecate list/table input of vars to `with-env`**
- **Remove examples for deprecated input**

# User-Facing Changes

## Deprecation of the following forms

```
> with-env [MYENV "my env value"] { $env.MYENV }
my env value

> with-env [X Y W Z] { $env.X }
Y

> with-env [[X W]; [Y Z]] { $env.W }
Z
```

## recommended standardized form

```
# Set by key-value record
> with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
╭───┬───╮
│ 0 │ Y │
│ 1 │ Z │
╰───┴───╯
```

## (Side effect) Repeated definitions in an env shorthand are now
disallowed

```
> FOO=bar FOO=baz $env
Error: nu:🐚:column_defined_twice

  × Record field or table column used twice: FOO
   ╭─[entry #1:1:1]
 1 │ FOO=bar FOO=baz $env
   · ─┬─     ─┬─
   ·  │       ╰── field redefined here
   ·  ╰── field first defined here
   ╰────
```
2024-04-16 19:08:58 +08:00
..
assert.nu Refactor error make (#10923) 2023-11-03 10:09:33 -05:00
dirs.nu Refactor error make (#10923) 2023-11-03 10:09:33 -05:00
dt.nu Refactor error make (#10923) 2023-11-03 10:09:33 -05:00
formats.nu Fixes #12482 by pointing help links for ndjson to a non-spam source (take 2) (#12509) 2024-04-13 18:59:43 -05:00
help.nu ♻️ rework some help strings (#12306) 2024-03-27 08:41:02 -05:00
input.nu Command to get individual keys (#9453) 2023-07-03 10:23:44 -05:00
iter.nu Add long options for filters (#10641) 2023-10-08 13:12:46 +02:00
log.nu fix std log (#12470) 2024-04-10 17:30:58 -04:00
math.nu move math constants to standard library (#9678) 2023-09-05 19:32:31 +02:00
mod.nu Improve with-env robustness (#12523) 2024-04-16 19:08:58 +08:00
xml.nu Refactor error make (#10923) 2023-11-03 10:09:33 -05:00