ble.sh icon indicating copy to clipboard operation
ble.sh copied to clipboard

`-bash: ble/builtin/trap/.handler: [...] -bash: ble/util/setexit: No such file or directory`

Open devidw opened this issue 4 months ago • 6 comments

$ ble summary

GNU bash, version 5.3.3(1)-release (aarch64-apple-darwin24.4.0)
ble.sh, version 0.4.0-devel4+14f98dd (noarch) [git 2.50.1, GNU Make 3.81, GNU Awk 5.3.1, API 4.0, (GNU MPFR 4.2.2, GNU MP 6.3.0)]
locale: LANG=en_US.UTF-8
terminal: TERM=xterm-kitty wcwidth=16.0-west/16.0-2+ri, tmux:0 (84;0;0)
options: -emacs +notify +vi +autocd +cdspell +inherit_errexit +login_shell

These lines are printed after each execution when using the vscode/cursor integrated terminal and I also get this in kitty sometimes, but only sometimes, vscode/cursor it's every time.

-bash: ble/builtin/trap/.handler: No such file or directory
-bash: ble/util/setexit: No such file or directory
Image Image

devidw avatar Aug 03 '25 15:08 devidw

This typically happens when set -o posix is set, but the problem doesn't arise with my environment (which is not VS Code or kitty).

  • Q1: What are the result of the following commands?
$ declare -p SHELLOPTS
$ builtin trap
  • Q2: Do you set set -o posix or POSIXLY_CORRECT=... in your shell configuration? Or do you set sh as the shell in the terminal's setting?

akinomyoga avatar Aug 03 '25 15:08 akinomyoga

Yes, posix is set. Shell is bash.

$ declare -p SHELLOPTS
bash: ble/builtin/trap/.handler: No such file or directory
bash: ble/util/setexit: No such file or directory
declare -r SHELLOPTS="braceexpand:hashall:histexpand:history:interactive-comments:monitor:notify:posix:vi"

And I can confirm that the lines disappear when opting out of posix.

So this is expected behavior then I assume, and one should disable posix when using ble.sh?

devidw avatar Aug 03 '25 16:08 devidw

  • Q1: What is the result of the following command?
$ builtin trap

So this is expected behavior then I assume, and one should disable posix when using ble.sh?

Bash 5.3 started to disable any function names containing / in the POSIX mode, so all ble.sh functions containing / in their function names as a namespace separator started to fail to work. Nevertheless, ble.sh tries to switch between POSIX (for user commands) and non-POSIX modes (for ble.sh's internal processing), so it is supposed to work. Ideally, all functions that can be called in the context of the user commands could be renamed to or wrapped in functions without / in their names, but what kind of functions may be called in the user-command context depends, so the information is needed.

akinomyoga avatar Aug 03 '25 17:08 akinomyoga

Aha interesting!

$ builtin trap
bash: ble/builtin/trap/.handler: No such file or directory
bash: ble/util/setexit: No such file or directory
trap -- 'ble/builtin/trap/.handler 0 "$BASH_COMMAND" "$@"; builtin eval -- "${_ble_builtin_trap_postproc[0]}" \# "${_ble_builtin_trap_lastarg[0]}"' EXIT
trap -- 'ble/builtin/trap/.handler 2 "$BASH_COMMAND" "$@"; builtin eval -- "${_ble_builtin_trap_postproc[2]}" \# "${_ble_builtin_trap_lastarg[2]}"' INT
trap -- 'ble/builtin/trap/.handler 28 "$BASH_COMMAND" "$@"; builtin eval -- "${_ble_builtin_trap_postproc[28]}" \# "${_ble_builtin_trap_lastarg[28]}"' WINCH
trap -- 'ble/builtin/trap/.handler 1000 "$BASH_COMMAND" "$@"; builtin eval -- "${_ble_builtin_trap_postproc[1000]}" \# "${_ble_builtin_trap_lastarg[1000]}"' DEBUG

devidw avatar Aug 03 '25 17:08 devidw

OK, so the DEBUG trap is present in your setup, and the trap string set by ble.sh is called through the DEBUG trap even in the user-command context. I could reproduce the problem:

$ bash --norc
$ source /path/to/ble.sh --norc
$ trap 'echo DEBUG' DEBUG
DEBUG
DEBUG
DEBUG
DEBUG
$ set -o posix
DEBUG
$ echo hello
bash: ble/builtin/trap/.handler: No such file or directory
bash: ble/util/setexit: No such file or directory
hello

I'll think about a good way to work around this.

akinomyoga avatar Aug 03 '25 22:08 akinomyoga

Appreciated!

devidw avatar Aug 03 '25 22:08 devidw