PowerShell / PowerShell/PowerShell
Automatic variable provider
Nadie ha tomado este issue todavía.
- 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
Reading the (recent) requests for additional automatic variables, I often see the general argument:
Adding an automatic variable might break existing scripts
Which is a valid argument but shouldn't be a valid argument. With nearly 50 automatic variables, this is going to look like a rookie mistake similar to using the <verb>-Variable cmdlets for dynamic variable names.
Most requests for new automatic variables are based on easy access or a clearer syntax. For the latter, I personally prefer the automatic variables as they do not require any parentheses (e.g. in the case of a cmdlet) or square brackets (e.g. in case of a hash table) when included in an expression.
Proposed technical implementation details (optional)
Afaik, a PSDrive reference of a provider might be used interchangeably with variable names:
$Env = 'foo'
$Env:temp
# C:\Users\user\AppData\Local\Temp
$Env
# foo
Which to my opinion means that if the automatic variables are contained by a separate PowerShell provider they shouldn't cause any break changes and even the provider name itself could afaik be something like $PS: or possibly just $: (probably as a syntactic sugar) as e.g.: $PS:Input or $:Input rather than: $Input.
Following the stackoverflow questions and answers closely, I can tell, almost every PowerShell starter falls into the automatic $Input variable pitfall.
Although an automatic variable provider won't fix that for the installed base, it will better allow for additional automatic variables (like $:now).
And in the future, I think it might be possible to remove about 90% of the current (potential conflicting) automatic variable names with an optional environment preference.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
No se han identificado archivos, pruebas ni puntos de entrada de implementación. Empieza revisando las solicitudes vinculadas sobre variables automáticas y el comportamiento del proveedor descrito en este issue. La tarea estaría completa cuando exista un diseño definido para el proveedor, la sintaxis de nombres, el comportamiento de compatibilidad y un alcance de implementación acordado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- powershell
- Área
- cli
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100