Skip to content
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

Printing output when resizing terminal window with a git prompt #78

Closed
3ximus opened this issue Dec 19, 2020 · 7 comments
Closed

Printing output when resizing terminal window with a git prompt #78

3ximus opened this issue Dec 19, 2020 · 7 comments
Labels
External Problem/Bug Problems/Bugs of other projects

Comments

@3ximus
Copy link

3ximus commented Dec 19, 2020

Hi, I'm back again :D

I find the reason of the problem I mentioned the other day.
It turns out its when some resizing happens on the terminal while inside a git repository. Here is a gif of the issue:

out

Also I noticed that if i detach and reattach the messages are different and might bring you some insight into the issue:

print

My prompt gets generated with this script https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
I don't know if it has something to do with it, but it doesn't happen in normal bash, so I'm guessing it is a problem with ble.sh

Cheers

@akinomyoga
Copy link
Owner

Thank you! I could finally reproduce the problem with the following simple ~/.bashrc.

# bashrc

source 3ximus.dotfiles/.bash/git-prompt.sh
source 3ximus.dotfiles/.bash/prompts/prompt_7.sh
source ~/.mwg/src/ble.sh/out/ble.sh

Now I can narrow down the problem at my side, so I think I can fix it soon!

@akinomyoga
Copy link
Owner

I got the following minimal test case that reproduces the job message. It seems Bash reports the forked processes in a trap handler as terminated jobs by the command jobs.

# bashrc
trap '(true); jobs' WINCH

I don't know if this is the intended behavior of Bash or just a bug, but it reproduces in all the Bash versions I tried (i.e., 3.0-5.1). I'll think about how we can work around this Bash behavior.

@3ximus
Copy link
Author

3ximus commented Dec 19, 2020

# bashrc
trap '(true); jobs' WINCH

Yeah, this seems to solve it. But I don't quite get it, so by trapping window resize with a call to jobs it doesn't display forked processes anymore? Shouldn't it do the opposite and actually display background processes after resizing?

@akinomyoga
Copy link
Owner

akinomyoga commented Dec 20, 2020

Yeah, this seems to solve it.

Oh, wait... I actually meant a different thing. The above setting was just a minimal reproducer of the messages and intended to be used without ble.sh. You can reproduce the strange messages by starting Bash with the single-line .bashrc,

$ bash --rcfile <(echo "trap '(true); jobs' WINCH")

and you will get job messages for ( true ) for each resize of the terminal.

But, yes, I now confirmed that this actually solves the problem when used with ble.sh. So, the current situation is:

without ble.sh with ble.sh
without trap ... WINCH OK job messages
with trap ... WINCH job messages OK

Actually, I'm not sure if this solution with trap ... WINCH is robust enough as I currently don't know why it works. I'm rather thinking of modifying ble.sh's code that tracks the job status change.

@akinomyoga
Copy link
Owner

I added a workaround bc4735e. Hope it works

@3ximus
Copy link
Author

3ximus commented Dec 20, 2020

Yup its working fine...
Yeah its kind of a weird fix, but background jobs still show up fine so it seems there aren't any apparent side effects !
If you find out more about it let me know, I'll close the issue.
Cheers mate, many thanks once again!!

@3ximus 3ximus closed this as completed Dec 20, 2020
@akinomyoga
Copy link
Owner

Thank you for checking!

Yeah its kind of a weird fix, but background jobs still show up fine so it seems there aren't any apparent side effects!

Actually, I used a different approach in bc4735e to solve the problem. Now it seems the workaround works, so there is no longer a problem with ble.sh. But now I'm interested in what is going on inside Bash, so I think I will look into the related Bash source code later when I have time.

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Problem/Bug Problems/Bugs of other projects
Projects
None yet
Development

No branches or pull requests

2 participants