Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
evolutics opened this issue Oct 13, 2020 · 1 comment

Comments

@evolutics
Copy link

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).

@lorenzo
Copy link
Member

lorenzo commented Apr 9, 2021

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants