nushell/crates/nu-command/src
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
..
bytes Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
charting Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
conversions Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
database Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
date Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
debug Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
env Improve with-env robustness (#12523) 2024-04-16 19:08:58 +08:00
experimental Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
filesystem making ls and du supports rest parameters. (#12327) 2024-04-13 15:03:17 +00:00
filters Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
formats Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
generators Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
hash Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
help Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
math Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
misc Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
network Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
path Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
platform Return value instead of stream from kill (#12480) 2024-04-12 10:44:27 -05:00
random Range refactor (#12405) 2024-04-06 09:04:56 -05:00
removed Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
shells Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
stor Fix typo in help stor import (#12442) 2024-04-07 08:09:24 -05:00
strings Fix nushell#10591: encode returns error with utf-16le and utf-16be encodings (nushell#10591) (#12411) 2024-04-06 09:07:55 -05:00
system Rename IoStream to OutDest (#12433) 2024-04-09 16:48:32 +00:00
viewers Copy-on-write for record values (#12305) 2024-04-14 01:42:03 +00:00
default_context.rs Use nightly clippy to kill dead code/fix style (#12334) 2024-03-30 09:17:28 +08:00
example_test.rs Initial --params implementation (#12249) 2024-03-24 15:40:21 -05:00
lib.rs Initial --params implementation (#12249) 2024-03-24 15:40:21 -05:00
progress_bar.rs remove cp-old (#11622) 2024-01-24 07:38:15 +08:00
sort_utils.rs Rename Value::CustomValue to Value::Custom (#12309) 2024-03-27 22:10:56 +01:00