Skip to content

Manual §8 Miscellaneous

Koichi Murase edited this page Oct 10, 2020 · 33 revisions

[ 日本語 | English ] ≫ Manual [§1 Intro | §2 Color | §3 Bind | §4 Edit | §5 Emacs | §6 Vim | §7 Comp | §8 Misc]

8. Miscellaneous

8.1 ble.sh shell variables

8.1.1 Shell variable BLE_VERSION

This variable contains the version string of the currently loaded ble.sh.

8.1.2 Shell variable BLE_VERSINFO

This array contains the version information of the currently loaded ble.sh The major version, minor version and patch level are contained from ${BLE_VERSINFO[0]} to ${BLE_VERSINFO[2]}. ${BLE_VERSINFO[3]} contains the commit ID of git. ${BLE_VERSINFO[4]} contains the release status such as devel, alpha, beta or release. ${BLE_VERSINFO[5]} always contains the value noarch, i.e., ble.sh does not depend on a specific system.

8.2 ble.sh functions

8.2.1 Function ble-import

Search file SCRIPTFILE from the specific paths, and sources the file if the file has not yet been sourced. When the option -d or --delay is specified, the loading is delayed if possible.

ble-import [-d|--delay] SCRIPTFILE

8.2.2 Function ble-autoload

This sets the delayed load for the function FUNCTION. When the function FUNCTION is called for the first time, ble-import SCRIPTFILE is called. SCRIPTFILE should contain the definition of FUNCTION. When shopt -s extdebug is set, the arguments for each function call are also output.

ble-autoload SCRIPTFILE FUNCTION...

8.2.3 Function ble-stackdump

This is the function for debugging purpose. It prints the information of call stack of shell functions.

ble-stackdump MESSAGE

8.2.4 Function ble-assert

This is the function for debugging purpose. First, COMMAND is evaluated by the eval builtin. If the command fails, the call stack information together with the message MESSAGE is printed.

ble-assert COMMAND [MESSAGE]

8.3 Bleopt variables for internal use

8.3.1 Bleopt internal_exec_type

# default
bleopt internal_exec_type=gexec   # ble-0.3 and later
bleopt exec_type=gexec            # ble-0.2 and before

It specifies the context of the command execution. The value gexec specifies that the user command is evaluated in global contexts. The value exec (ble-0.3 and before) specified that the user command is evaluated in a function, but the support is removed in ble-0.4 because this is only remained for a debugging purpose and not tested well.

8.3.2 Bleopt internal_ignoreeof_trap (Text)

# default
bleopt internal_ignoreeof_trap='Use "exit" to leave the shell.' # ble-0.3 and later
bleopt ignoreeof_message='Use "exit" to leave the shell.'       # ble-0.2 and before

This option sets the message that Bash outputs when C-d is input by user. This value is used to detect that the user inputs C-d in Bash 3.

8.3.3 Bleopt internal_suppress_bash_output (Empty/Non-empty)

# default
bleopt internal_suppress_bash_output=1  # ble-0.3 and later
bleopt suppress_bash_output=1           # ble-0.2 and before

When a non-empty value is specified to this option, the standard output and standard error from Bash is not output to the terminal. When the value is empty, ble.sh tries to realize the line editing allowing Bash to output its own standard output and error. This setting has a flickering problem and only left for debugging purpose, so it is not tested. Normally a non-empty value should be specified so as to suppress the standard output and error from Bash.

8.3.4 Bleopt internal_stackdump_enabled (Arithmetic) (v0.2)

# default
bleopt internal_stackdump_enabled=0   # ble-0.3 and later
bleopt stackdump_enabled=0            # ble-0.2

This option controls the output of stack dump when assertion is failed in ble.sh. When the value is evaluated to be non-zero, the stack dump is printed for assertion failures.

8.3.5 Bleopt history_lazyload (Empty/Non-empty)

# default
bleopt history_lazyload=1

When this option has a non-empty value, delayed loading of history is enabled. This is enabled by default. When the value is empty, the user input is processed after completing the history loading on ble-attach.

8.3.6 Bleopt idle_interval (Arithmetic) (v0.3)

# default
bleopt idle_interval='ble_util_idle_elapsed>600000?500:(ble_util_idle_elapsed>60000?200:(ble_util_idle_elapsed>5000?100:20))'

This option sets the interval of checking new user inputs. The value is evaluated as an arithmetic expression. On the evaluation, a shell variable ble_util_idle_elapsed is provided for the time since the last user input in millisecond. This option is used for the polling for the background execution when there is no user inputs.

8.3.7 Bleopt openat_base (Integer)

# default
bleopt_openat_base=30

This setting needs to be set before ble.sh is loaded. Therefore the value should be assigned directly to the shell variable bleopt_openat_base instead of using bleopt command. This setting specifies the starting number of the file descriptors which ble.sh internally uses. The value of this setting is used as the number for the first file descriptor of internal use, and the next value is used for the second file descriptor, and so on. When you want to use the default value 30 and succeeding number 31, 32, etc. for other purposes, please set to this settings another value which does not collide with file descriptors of other purposes.

8.3.8 Bleopt syntax_debug (空/非空)

# default
bleopt_syntax_debug=

When a non-empty value is specified to this option, displays the internal syntax analysis information and the syntax tree. This is only effective in devel versions.

8.4 Limitations of ble.sh

ble.sh overwrites the user settings by .inputrc or by builtin command bind. ble.sh tries to read .inputrc on load, and also translate the call of bind for ble.sh by overwriting the builtin bind by a shell function bind. However, currently the call of bind before the source of ble.sh is not reflected in ble.sh. When you rite .inputrc, the settings only applied to ble.sh can be written in the following way.

# inputrc

$if Blesh

# Settings for ble.sh

$endif

ble.sh internally uses the following traps. In ble-0.4 and later, ble.sh overwrites trap by a shell function so that users do not have to care about the existing traps by ble.sh on setting the user traps. Note that users needs to use trap but not builtin trap.

# ble-0.4
builtin trap -- 'ble/builtin/trap/.handler 0 EXIT; builtin eval -- "$_ble_builtin_trap_hook"' EXIT
builtin trap -- 'ble/builtin/trap/.handler 2 INT; builtin eval -- "$_ble_builtin_trap_hook"' SIGINT
builtin trap -- 'ble/builtin/trap/.handler 28 WINCH; builtin eval -- "$_ble_builtin_trap_hook"' SIGWINCH
builtin trap -- 'ble-edit/exec:gexec/.TRAPDEBUG "$*" || { (($?==2)) && return 0 || break; } &>/dev/null' DEBUG

# ble-0.3
builtin trap -- 'ble-edit/exec:gexec/.eval-TRAPINT' INT
builtin trap -- 'ble/base/unload' EXIT
builtin trap -- 'ble-edit/attach/TRAPWINCH' WINCH

# Bash 3.2 and before
builtin trap -- 'ble-edit/bind/stdout/TRAPUSR1' USR1

# Currently not used
# builtin trap -- 'ble-edit/bind/.exit-TRAPRTMAX' RTMAX

ble.sh internally uses several file descriptors starting from ${bleopt_openat_base:-30}. Users should not change these file descriptors using exec.

ble.sh prohibits overwriting the following commands and keywords using shell functions or aliases. Even if users overwrites these commands and keywords, ble.sh tries to unset the functions or aliases.

  • Builtins: builtin enable unalias return break continue declare typeset local eval :
  • Keywords: if then elif else case esac while until for select do done { } [[ function

ble.sh overwrites the builtin unset by a readonly function that explicitly performs builtin unset so that other function cannot overwrite unset.


[ 日本語 | English ] ≫ Manual [§1 Intro | §2 Color | §3 Bind | §4 Edit | §5 Emacs | §6 Vim | §7 Comp | §8 Misc]