sorawee / fmt

A code formatter for Racket
Other
72 stars 6 forks source link

No output to standard out in case of error #44

Open amosnier opened 1 year ago

amosnier commented 1 year ago

Was discussed in https://github.com/sorawee/fmt/issues/43, but I now create a specific issue, for the sake of clarity. @sorawee, please feel free to (re-)close https://github.com/sorawee/fmt/issues/43 if you think nothing should be done about the comment "issue".

Minimal example for this issue:

$ raco fmt 4 4

Please note that after the first 4, I press <return> and <ctrl-d>. raco fmt then outputs my unchanged input, which is what I expect. On the other hand:

$ raco fmt (define 1:1:0: expected a ) to close ( context...: /usr/local/share/racket/collects/syntax/readerr.rkt:15:2: -raise-read-error .../match/compiler.rkt:559:40: f123 /home/alain/.local/share/racket/8.8/pkgs/fmt/read.rkt:123:0: read-top /home/alain/.local/share/racket/8.8/pkgs/fmt/main.rkt:27:0: program-format /home/alain/.local/share/racket/8.8/pkgs/fmt/raco.rkt:115:0 body of "/home/alain/.local/share/racket/8.8/pkgs/fmt/raco.rkt" /usr/local/share/racket/collects/raco/raco.rkt:41:0 body of "/usr/local/share/racket/collects/raco/raco.rkt" body of "/usr/local/share/racket/collects/raco/main.rkt"

That is when pressing <return> and <ctrl-d> after (define. There my input is gone, which might be intended, but makes the program unusable as a filter, as far as I know.

For the sake of completion, what raco fmt -i does is as far as I know perfectly fine. This issue is only relevant when the output is sent to standard out (and standard error) in case of error. Getting the error message to standard error is then perfectly fine too, since it can easily be redirected. The issue in this case is that nothing comes to standard out. That prevents the program from being used as a true filter, which would be composable through pipelines (typical UNIX principle). In that case, just outputting the input to standard out would solve this issue.

sorawee commented 1 year ago

Thanks! I'm currently busy with deadlines. Will take a look after my life is better.

amosnier commented 1 year ago

For the record, I have created raco-fmt-or-cat for my own short term needs. And of course, that's because I really like raco fmt, by the way.

amosnier commented 1 year ago

Please see https://github.com/benknoble/vim-racket/issues/11#issuecomment-1468604099. What I'm explaining in that comment is basically that I no longer consider what I described here as an issue. In other words, as far as I am concerned, this issue may be closed. I will also make my workaround private, as I would not recommend anybody to use it.