language-docker icon indicating copy to clipboard operation
language-docker copied to clipboard

Pretty printing of `RUN` in shell form replaces multiple spaces in quoted string

Open evolutics opened this issue 4 years ago • 1 comments

First of all, thanks for this helpful library.

The Dockerfile

FROM alpine
RUN echo 'a    b'

is pretty printed by prettyPrint as

FROM alpine
RUN echo 'a b'

I'd expect a quoted string to be left unchanged instead of reduced to 'a b'.

This happens not only with RUN instructions (in shell form), but also with health check commands.

A minimal code example is

module Main
  ( main
  ) where

import qualified Data.Either as Either
import qualified Data.Text as T
import qualified Data.Text.IO as T.IO
import qualified Data.Text.Lazy as Lazy
import qualified Language.Docker as Docker
import Prelude (IO, ($))

main :: IO ()
main = T.IO.putStr prettyPrinted
  where
    prettyPrinted = Lazy.toStrict $ Docker.prettyPrint parsed
    parsed = Either.fromRight [] $ Docker.parseText source
    source = T.pack "FROM alpine\nRUN echo 'a    b'\n"

I'm using version 9.1.1 of the library (via LTS Haskell 16.18).

evolutics avatar Oct 13 '20 20:10 evolutics

@evolutics I'm sorry this flew under my radar for so long. I've been considering for a long time to just store the raw parsed text for RUN into the record so the pretty print does nothing with it at all.

I'll see if I can hack something together in the coming days

lorenzo avatar Apr 09 '21 14:04 lorenzo