Closed ragnarov closed 4 months ago
You seem to use ble-0.3. There are many adjustments related to modifyOtherKeys
in ble-0.4, so could you please check if the problem also arises in ble-0.4?
ble-0.4.0-devel3.tar.xz In this version, the issues don't exist so far as I have seen.
Hmm, in that case, I wouldn't fix ble-0.3 because so many changes have been implemented for the terminal detection in ble-0.4, and it is not simple to backport all of them to ble-0.3. Would you mind using ble-0.4 instead of ble-0.3?
I will use ble-0.4 now.
But something else I forgot to mention,
If I start a shell from within ranger by pressing S, and then quit the shell with exit or ctrl+d
shift key no longer works, instead I get :
in command bar of ranger.
ranger -> bash -> quit -> back to ranger
problem occurs
if I start ranger (say 1) from ble.sh session, this problem don't occur, however if I start a nested bash session from within this ranger (1) session, and quit that bash session, and then try to press shift, the same problem occurs.
bash(ble.sh) -> ranger -> bash(ble.sh) -> quit -> back to ranger
problem occurs
This same problem with shift key and ranger existed in ~0.3
shift key no longer works, instead I get
:
in command bar of ranger.
Thank you for the information, but what does "shift key no longer works" mean? I'm not familiar with ranger
, but as far as I test, just pressing shift doesn't seem to do anything even without ble.sh.
It does something when the shift key is combined with the s key to produce S as you describe. But, that still works after starting a ble.sh session by pressing S and exiting the ble.sh session by running exit
or pressing C-d. In this sense, the shift key seems to continue to work even after exiting from the inside ble.sh session in my environment.
How can I check or did you check whether "shift key works"? I think with the normal setup, just pressing shift doesn't do anything by default. The shift key needs to be combined with any other key to cause an action. Then, it is unclear whether you have an effect even without combining shift with another key or you combine the shift key with a key that you didn't describe.
thank you for replying, shift key works as in shift + s = S
so, if I start ranger from bash, shift key works as previously said (shift + s = S)
but bash -> ranger -> bash (shift + s) -> back to ranger (exit) -> now in ranger, shift + s first gives :, and then if I press s again, without lifting shift, I get this : [27;2;83~
But it seems this happens only in foot
, don't happen in lxterminal
, and urxvt
What software did you use to record your ble.sh session, with the key press shown at bottom right?
OK, I tried other terminals, and I found that the behavior seems to reproduce in mintty
when I exit the inside session with C-d. The behavior doesn't seem to reproduce when I exit the inside session by running exit
.
What software did you use to record your ble.sh session, with the key press shown at bottom right?
That is a Windows software. A modified version of brookhong/KeyCastOW
.
I agree, I was wrong.
The problem only occurs when exiting the "inside bash" session using c-d
for foot
terminal
and the problem stays in ranger only, if I exit ranger session,
And drop to the "first bash" session, and then start ranger again,
There is no problem.
But If I again start another "inside bash" session, and then exit that with c-d
,
The ranger session again has this problem.
If I exit ranger, this is fixed (as in launching a new ranger session doesn't have this problem)
Edit: Here is a small demonstration I created.
Sorry for the delay, but I'll later fix it on my side as I can reproduce the problem in my environment. After fixing it, I'll push the fix and ask you to check the behavior in your environment.
I pushed a fix 38a8d571502c699c3b23f8d9313756870862f131. Could you update ble.sh by running ble-update
and see if the problem is fixed?
Summary: The behavior of the EXIT
trap has changed from Bash 5.2, which caused the issue. When the exit
command is called inside a function, the EXIT
trap was called after we went out from the function in Bash < 5.2. However, from Bash 5.2, the EXIT
trap started to be called from inside the function. When stdout/stderr of the function call is redirected, the EXIT
trap is also affected by the redirections from Bash 5.2. See the following example:
$ bash-5.1 -c 'trap "echo hello" EXIT; function fn { exit; }; fn &>/dev/null'
hello
$ bash-5.2 -c 'trap "echo hello" EXIT; function fn { exit; }; fn &>/dev/null'
$
For this reason, necessary terminal control sequences to restore the terminal state did not reach the terminal when the ble.sh session terminated in a specific way in Bash 5.2. The fix was to explicitly redirect the output to the terminal inside the EXIT
trap.
Thank you so much.
That issue has been fixed, But there is a new issue now.
When I start the "inside bash session" from ranger, I get the following,
using foot
terminal.
[i]bash-5.2$ ranger
[i]bash-5.2$ bash: 33: Bad file descriptor
bash: 33: Bad file descriptor
bash: 33: Bad file descriptor
bash: 33: Bad file descriptor
This is what I get using lxterminal
right when I launch the terminal.
meaning original ble.sh
session
[i]bash-5.2$ ranger
[i]bash-5.2$ bash: 33: Bad file descriptor
bash: 33: Bad file descriptor
bash: 33: Bad file descriptor
bash: 33: Bad file descriptor
Edit:
okay, after rebooting, that issue is gone.
But here is what I get when exiting "inside bash session" using c-d
or exit
:
[i]bash-5.2$ ranger
[i]bash-5.2$ exit
[ble: exit]
ble: Please run `stty sane' to recover the correct TTY state.
[i]bash-5.2$
For both foot
and lxterminal
When I start the "inside bash session" from ranger, I get the following,
It should be related to f940696f. I expected it to happen when the new version of ble.sh in a child Bash is started in a parent Bash with an old version of ble.sh, so I thought I added a guard to prevent it from happening. But maybe the guard didn't work properly, or there is a case that I overlooked. I'll later try to replicate it.
But here is what I get when exiting "inside bash session" using
c-d
orexit
:[i]bash-5.2$ ranger [i]bash-5.2$ exit [ble: exit] ble: Please run `stty sane' to recover the correct TTY state. [i]bash-5.2$
For both
foot
andlxterminal
That's expected. That is a workaround for Bash 5.2's EXIT trap. When the parent process is not a ble.sh session, the user needs to run stty sane
. ble.sh also runs a command equivalent to stty sane
, but Bash 5.2 again changes back the TTY state after ble.sh adjusts it.
But I recently added another fix 38a8d571, which might fixed the original problem. I'll take a look.
It took some time to investigate them, implement the solutions, and test the fixed version, but I now pushed the fixes.
This is what I get using
lxterminal
right when I launch the terminal. meaning originalble.sh
session[i]bash-5.2$ ranger [i]bash-5.2$ bash: 33: Bad file descriptor bash: 33: Bad file descriptor bash: 33: Bad file descriptor bash: 33: Bad file descriptor
Edit: okay, after rebooting, that issue is gone.
I added a workaround for this in commit 785267e
. Even though the error only happened when different versions of ble.sh
were mixed, it shouldn't have happened ideally. Now I believe the error of the bad file descriptor doesn't happen in the latest version even when there are file descriptors prepared by previous versions of ble.sh
.
But here is what I get when exiting "inside bash session" using c-d or exit:
[i]bash-5.2$ ranger [i]bash-5.2$ exit [ble: exit] ble: Please run `stty sane' to recover the correct TTY state.
As I've explained in my previous reply, this was a workaround for the recent Bash version and actually expected. However, after that, I again took the time to investigate what was happening there. Then, I found the root cause and added a better workaround in commit 4b8a07994d67ebcba4771130c1689b9b8767bad6. Now I removed the message ble: Please run `stty sane` to recover the correct TTY state
.
@ragnarov Is everything fine? Can I close the issue?
yes please, thank you so much for replying and fixing these issues.
Thank you for all your reports!!
ble version: 0.3.4+566651e bash version: 5.2.21(1)-release (x86_64-unknown-linux-musl) distro: void linux
after launching terminal (foot), and then starting
fish
, if I use ctrl+A or ctrl+E or shift+I, escape codes are printed, using foot terminal. I faced similar problems trying to use weechat. forctrl+A
I get[27;5;97~
forctrl+E
I get[27;5;101~
forshift+I
I get[27;2;73~
forctrl+U
I get[27;5;117~
If I typereset
inbash
session and then launchfish
, this don't happen using foot terminal. If I typereset
infish
session and then quit to bash using ctrl+d and then launch fish again from the same bash session, this problem don't happen using foot terminal. If I typereset
inbash
session, and then start weechat, I don't face any problem. Everything works normally. This problem don't happen in xterm at all.my bashrc is given below. despite what it looks like, I used this exact bashrc to make sure the problem is not with whatever I am doing in the middle. But I am not sure.
some more info: