PowerShell / PowerShell/PowerShell

Splatting for native commands results in incompatible syntax for modern commands

Abierto
#20,068 3 comentarios 4 reacciones 1 asignado Ver en GitHub

@SeeminglyScience ya está trabajando en esto.

Desde el 14/11/2023.

Issue-Enhancement Needs-Triage WG-Engine WG-NeedsReview
Lenguaje dominante
C#
Estrellas
55.5k
Forks
8.5k
Merge medio
1 d 2 h
PR fusionados (30 d)
88

Descripción

Summary of the new feature / enhancement

Since PS5.1, splatting to a native commands results in a single - prefix and a : separator between the parameter name and the parameter value.

$a = @{a=1;bb=2}
echoit @a

Expected where the convention is a single character parameter is prefixed by a single dash and a spelled out parameter is prefixed by two dashes and parameter values are space separated:

echoit -a 1 --bb 2

Actual:

echoit -a:1 -bb:2

The current behavior means this doesn't work with most modern commands. If the hashtable is converted to an array, you can get some of the right behavior as splatting an array always means separate parameters and prefixes need to be defined within the array.

Proposed technical implementation details (optional)

If we are ok with a breaking change as it could be a bucket 3 item, then we use the logic that single character parameters are prefixed by single dash while multi-character parameter names are prefixed by a double-dash.

If we need to support -, --, /, etc... explicitly as well as :,=, etc.. separator, then we could have a predefined special member of the hashtable that defines those options:

$params = @{
  _prefix = '/'
  _separator = '='
  arg1 = 1
  arg2 = 2
}

I'm choosing the underscore so it minimizes conflicts with existing parameter names. There is a discovery problem that can only be solved by docs or a feedbackprovider that sees splatting and the native command failing and pointing to the docs.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.