-
Notifications
You must be signed in to change notification settings - Fork 12
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
using pipe-rename in a pipe seems to misconfigure terminal #54
Comments
Still looking into this, but it appears that This documentation could be interesting: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer (potentially also relevant ... and linking to the aforementioned) Generally this seems to occur only when piping something into |
Your problem is simple. you need to terminate vim, before you exit your program. here's your error mode: launch vim, vim exits, you return to shell, then vim cleans up. you need vim to clean up before you return to shell. I'll save myself from poking around in yer code to find what causes this, but whatever is wrapping vim isn't closing the pipes early. I hope this doesn't waste you an hour looking for a missing close() but I think this is the problem. '*** this is unituitive, because the shell launches piped processes in a separate process, and the last program can exit before the other piped processes exit normally. |
And it may be due to me not being a native speaker of English, but I have trouble comprehending what it is you are trying to say. Whenever I use Vim it works fine. So to me the question is why it doesn't work with your Perl script but does with Vim. I was surmising it could have to do with how Vim uses the alternate screen buffer. You seem to have a different view, right? Are you saying that |
Good wishes for 2023 to you. I am saying that the subshell from
should not exit before the new vim process manages to clean up the terminal. Honestly I'm not sure if the problem is that your program is exiting early, or if the problem is closing the pipe early. So here is what I don't know: Scenario 1: pipe-rename exits too early, and vim cleans up after exit() https://brandonwamboldt.ca/how-linux-pipes-work-under-the-hood-1518/ Cheers |
Alright, slowly understanding what you wrote. Additionally I ran a test on Linux, where this can be reproduced all the same. For starters we record the sane terminal settings (also see attached files):
Then we "mess it up" using Vim, invoked by renamer which in turn gets its input from stdin:
At this point Enter won't produce a line break anymore. But we can still execute commands. For example another One thing I am puzzled about, though, is whether one should simply invoke Further reading: |
You'll figure it out soon enough. Look at my last comment- scenario #1 and scenario #2 the problem has nothing to do with the terminal. It has everything to do with the bash subshell cleaning up the terminal before vim exits. it means the order of operations is wrong. instead of calling vim, call this bash script #!/bin/sh echo -e "ok test\n" | vim - the sleep command will prevent the subshell from exiting before vim exits. The subshell doesn't exit because we haven't closed STDIN. |
$ echo unum.pl |renamer
This should work well, but instead on exit from vim, my terminal doesn't convert line endings correctly anymore. I'm using vim 8.2.1525. bash 5.1.4.
I think your project is fine, and some new ideas, which is why I'm using it in my mpvreadname project.
If you used a temporary file I think the problems would go away. please remember bash might close the piping subshell after it reconfigures the terminal for the bash prompt and readline.
The text was updated successfully, but these errors were encountered: