You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that after running tofu fmt in lefthook there are remaining color codes in the shell. So this might not be a lefthook issue but a tofu issue.
When running tofu fmt filename.tf this does not happen however, so my guess would be this has something to do with the colored output of lefthook.
It is also worth noting that tofu fmt does not output anything to the shell if no changes were made/all files were already correctly formatted. If tofu fmt changes a file because it was not formatted correctly the file name of the changed file is written to the terminal.
This does not affect the result though, the color code is "printed" wether tofu fmt changes files or not.
I have tested this on sh, bash and zsh (with prezto + starship) and have gotten the same results. The tests described below and the logs in the end were with bash.
Lefthook version
1.10.3 24a3aff (also tested on latest version 1.10.10, same results)
There are no color codes remaining in the shell after the command completes.
Actual results
Color codes remain in the shell, i.e. 11;rgb:ffff/fafa/f3f3;1R^C
Possible Solution
Have not found one yet.
I tried running lefthook with --colors off though this did not help:
I tried running tofu fmt -no-color {staged_files} instead in the .lefthook.yaml (tofu fmt does not have a -no-color parameter documented so I don't think this does anything, the parameter exists for other tofu functions though)
I tried running a combination of the above
All these resulted in the same result: there are remaining color codes in the prompt.
When running a different command (such as echo or tflint) instead of tofu fmt this issue did not occur.
🔧 Summary
It appears that after running
tofu fmt
in lefthook there are remaining color codes in the shell. So this might not be a lefthook issue but a tofu issue.When running
tofu fmt filename.tf
this does not happen however, so my guess would be this has something to do with the colored output of lefthook.It is also worth noting that
tofu fmt
does not output anything to the shell if no changes were made/all files were already correctly formatted. Iftofu fmt
changes a file because it was not formatted correctly the file name of the changed file is written to the terminal.This does not affect the result though, the color code is "printed" wether
tofu fmt
changes files or not.I have tested this on sh, bash and zsh (with prezto + starship) and have gotten the same results. The tests described below and the logs in the end were with bash.
Lefthook version
1.10.3 24a3aff (also tested on latest version 1.10.10, same results)
Steps to reproduce
.lefthook.yaml
.tf
filelefthook run pre-commit
Expected results
There are no color codes remaining in the shell after the command completes.
Actual results
Color codes remain in the shell, i.e.
11;rgb:ffff/fafa/f3f3;1R^C
Possible Solution
Have not found one yet.
--colors off
though this did not help:tofu fmt -no-color {staged_files}
instead in the.lefthook.yaml
(tofu fmt
does not have a-no-color
parameter documented so I don't think this does anything, the parameter exists for other tofu functions though)All these resulted in the same result: there are remaining color codes in the prompt.
When running a different command (such as
echo
ortflint
) instead oftofu fmt
this issue did not occur.Logs / Screenshots
The text was updated successfully, but these errors were encountered: