Hi,
I'm trying to execute vim
(or any interactive commandline program/editor) from rust but that leaves the terminal trashed... I'm not sure how to do it properly (I'm sure it can be done).
My setup is a bit unusual, so I'll explain it here:
- User executes
echo foo | imag edit -I
- The
imag
binary finds "edit" as command and executesimag-edit
, passing all parameters -
imag-edit
finds the-I
parameter which means it should read the path of the file to edit from stdin -
imag-edit
reads from stdin. It readssome/path/foo
, copies its content to a temporary file -
imag-edit
opensvim
on that temporary file - after vim is closed,
imag-edit
reads the temp file and writes its contents back to the original file.
Somewhere in this process something works not as intended and vim leaves the terminal trashed.
- The
Command
building in theimag
binary is located here - The
Command
building for the editor is located here (if I change the stdin to be inherited, that does not help and the same trashing of terminal happens) - The
imag-edit
reading from commandline is located here - The calling of the editor command is located here
I'm not sure what the actual issue is. I inherit stdin
everywhere (if I do it in libimagrt it does not work either, as stated above)... so either that is wrong or I'm missing something.
I'm a bit at loss and would appreciate some help.
Edit: Related issue here