Closed halostatue closed 1 year ago
The commit message has been updated to reflect a number of changes required. Please note that this PR now also contains a bug fix for ruby#rubocop
when the $SHELL
is not bash
or zsh
(I use fish
). There may be other formatters that require similar fixes.
The key point of the updated commit message -- and the bug fixed -- is described below:
Adjusted the error output remover for ruby#rubocop
and used the same for ruby#standard
. The previous version had multiple issues.
If the default shell was not more-or-less POSIXly correct (e.g., bash or zsh), the sed recipe might not run correctly because the regex line terminator ($
) might result in an attempt to interpret that as a variable. On my macOS machine with fish as my $SHELL
, I was getting "could not open file /tmp/…" errors.
If there were no errors reported, the terminator line would be found on line 1, which means that it would not be found again, and the format step would clear the file. The cleanest sed-based fix depends on a GNU sed extension, 0,/^====================$/d
. This is not how non-GNU seds work, so in the same SO answer where I found
the extension, I also found the awk statement used here. I have tested it with constructs that produce errors and those without; only the errors are removed and the reformatted code is returned. It works with both rubocop and standard.
https://stackoverflow.com/questions/17364951/remove-all-lines-before-a-match-with-sed
Because the awk statement is relatively complex, it is put into a file-local variable and reused that way.
@sbdchd
Is it possible get this reviewed?
Sorry for the delay!