-
-
Notifications
You must be signed in to change notification settings - Fork 86
Note
Actually, no. The entire codebase of ble.sh
is not perfectly written
in pure Bash. Although the core part of the line editor is written in
completely pure Bash, initialization codes, history manipulations,
completion, etc. use external commands for the environment setup and
efficiency. Here are the categories of the use of external commands
with their reasoning.
-
(init) Some initialization codes of
ble.sh
use external commands such asmkdir
,chmod
,rm
,readlink
, which cannot be replaced by any pure Bash functionality. Also, finalization codes userm
. -
(perf) Some computationally costly operations such as history manipulations (with many history entries) and completion (with many possible completions) use external commands such as
awk
,sed
, andsort
. In principle, it is possible to implement these processes in pure Bash script, but it is too slow. We think the user experience is more important that the fact thatble.sh
is really entirely written in pure Bash script. -
(compat) There are several Bash functionalities that are not present in older Bash versions. For such functionalities,
ble.sh
uses external commands as fallback in old versions of Bash. -
(diag) Some codes for diagnostics (debugging
ble.sh
itself) use external commands. -
(user) When executing user commands which are supplied through the commandline, progcomp settings, hooks such as
PROMPT_COMMAND
, etc., external commands in these user commands are of course executed. In addition to this,ble.sh
usesstty
command to set up the correct TTY settings for these user commands. Also, when the user invoked the command help functionality,man
will be executed.completion
also usesman
to obtain the list of available commandline options.
Here are the list of the uses of external commands in ble.sh
(last updated 2020-11-11):
- (init) ble.pp:
rm
,mkdir
,chmod
,readlink
- (init) def.sh (blehook/.compatibility-ble-0.3/check):
cat
- (init) util.sh (ble/util/declare-print-definitions):
awk
for fixing buggy output ofdeclare -p
of various versions of Bash. - (init, perf) decode.sh (ble/decode/cmap/initialize):
awk
- (init, perf) decode.sh (ble/decode/readline/.generate-source-to-unbind-default):
awk
- (init, perf) decode.sh (ble/builtin/bind/read-user-settings):
sed
,mv
,awk
- (compat <= 4.3) util.sh (ble/util/msleep):
rm
,mkfifo
,sleep
,sleepenh
,usleep
, etc. - (compat <= 4.3, init) edit.sh:
tty
to obtain TTY name for PS1\l
- (compat <= 4.1) util.sh (ble/util/strftime):
date
- (compat <= 3.2) edit.sh:
grep
,rm
,mkfifo
to capture the user input C-d - (user) util.sh (ble/term/stty):
stty
- (user, perf) decode.sh (ble-bind -L):
sed
- (user) util.sh (ble/util/pager):
less
,pager
,more
, etc. to show information to the user. - (user) edit.sh:
man
,awk
to show command help. - (user) complete.sh:
man
,gzip
,nroff
,mkdir
to extract and cache man information to generate completions - (diag) util.sh (ble/debug/setdbg):
rm
,readlink
- (diag) benchmark.sh (ble-measure):
awk
to floating-point calculation - (perf) decode.sh (ble/decode/nonblocking-read):
od
when there are massive user inputs - (perf) history.sh:
awk
,mv
,sed
,wc
for command history manipulations - (perf) core-complete.sh:
grep
,sed
,awk
,sort
for manipulating the list of possible completions - (unused) util.sh (ble/util/getmtime):
date
,stat
[Note: this function is currently not used byble.sh
itself]