randy3k / Terminus

Bring a real terminal to Sublime Text
https://packagecontrol.io/packages/Terminus
MIT License
1.38k stars 84 forks source link

process is terminated with return code 127 #316

Closed haurat closed 1 year ago

haurat commented 2 years ago

Well, most of the times when I try to close the Terminal panel using a simple 'exit' command (I'm on Linux mint), this error is shown and it does not even get closed. Please look into it :)

randy3k commented 2 years ago

The view is only automatically closed when the process ends with return code 0. For some reasons, your process returns 127 when you run exit.

rafern commented 2 years ago

I had the same issue using zsh. It turns out that, according to the docs (shell built in commands section), the exit command returns the last exit code instead of just 0, which is kinda weird but also makes sense for scripting. So, if you run a command successfully and then exit, the shell will close cleanly, but if you run a command that has an error and then you exit, then the shell will close with whatever exit code the last command failed with. If you type a command that doesn't exist, the shell will set the last exit code to 127, so if you misspell a command and then exit, your shell will close with an exit code of 127, which is probably what happened.

TLDR use exit 0 instead of exit

randy3k commented 2 years ago

I had the same issue using zsh. It turns out that, according to the docs (shell built in commands section), the exit command returns the last exit code instead of just 0, which is kinda weird but also makes sense for scripting. So, if you run a command successfully and then exit, the shell will close cleanly, but if you run a command that has an error and then you exit, then the shell will close with whatever exit code the last command failed with. If you type a command that doesn't exist, the shell will set the last exit code to 127, so if you misspell a command and then exit, your shell will close with an exit code of 127, which is probably what happened.

TLDR use exit 0 instead of exit

Thanks for the investigation.

brupelo commented 2 years ago

Not sure if this is related but here's a similar issue I'm facing:

image

So basically if i run exit the process will hang and the terminus view won't close as it should

kapitanluffy commented 1 year ago

Is it possible to make terminus exit regardless of return code?

rosbly commented 1 year ago

Hi,

This is a major issue for my usage, because I typically use toggle_terminus_panel to open the terminal (Bash, in Linux or in WSL), apply a few commands, then exit with Ctrl+D. If the last command returned non-zero (which is a usual case), then toggle_terminus_panel becomes ineffective: I have to restart SublimeText to use the terminal again.

The solution is not to use exit 0, Terminus is a terminal emulator and should simply ignore the return code (or at least provide an option to do so, if someone has any use of being warned of a non-zero retcode - though I can't see any reason to care).

That's the only big problem with Terminus - Great plugin, thanks! Syl

randy3k commented 1 year ago

It should be fixed by https://github.com/randy3k/Terminus/commit/c3ff44e0e45a15a1c9a64be7e63d5c7d3d32a3a7.

rosbly commented 1 year ago

Great, thank you!

falsefalse commented 1 year ago

Why though? 😿 😿 😿

It was so useful for build systems — if build (or linter) fails, you get to see the errors, and if not — panel gets hidden. Now errors are immediately closed without a way to even see them.

This sounds like having "auto_close_on_clean" option or something, not sure about the approach here @randy3k

@rosbly you don't have to restart cmd+shift+p → terminus: close all, cmd+shift+p → terminus: reset et voila

randy3k commented 1 year ago

Maybe auto close could take a few options like true, false and on_clean.