`RUN` is formatted as POSIX shell after `SHELL` switches to PowerShell or cmd

Abierto
#72 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, go
Área
tooling

Línea de trabajo

Start by tracing how dockerfmt parses and formats shell-form RUN, CMD, and ENTRYPOINT instructions, then follow how the Dockerfile SHELL instruction is represented and used. Reproduce with the PowerShell example in the issue and inspect existing formatter tests. Done means shell-form bodies remain unchanged after a non-POSIX SHELL instruction, with tests covering the reported panic and unwanted rewriting.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

RUN commands are always parsed and formatted as POSIX shell, even after a SHELL instruction switches to PowerShell or cmd. Depending on the command, dockerfmt either panics or silently rewrites it using shell quoting rules.

Reproduce
FROM mcr.microsoft.com/powershell
SHELL ["pwsh", "-Command"]
RUN if ($true) { Write-Host hi }
dockerfmt Dockerfile
Actual

Exit code 2:

Error parsing: if ($true) { Write-Host hi }
panic: 1:12: statements must be separated by &, ; or a newline

A command that happens to parse as shell gets rewritten instead:

SHELL ["pwsh", "-Command"]
RUN Get-ChildItem -Path C:\ | Select-Object Name

becomes

RUN Get-ChildItem -Path C:\  | Select-Object Name

because shell reads \ as an escaped space.

Expected

After a SHELL instruction that selects a non-POSIX shell, leave the shell-form RUN, CMD and ENTRYPOINT bodies untouched. That is the usual setup for Windows images.

Reproduced with v0.5.4 and with main at a5868c2.

Lenguaje dominante
Go
Estrellas
626
Forks
23
Merge medio
6 d 23 h
PR fusionados (30 d)
3

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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.

Más de reteps/dockerfmt

Todos los issues de reteps/dockerfmt

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.