-
-
Notifications
You must be signed in to change notification settings - Fork 113
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.shuse 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.shis 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.shuses external commands as fallback in old versions of Bash. -
(diag) Some codes for diagnostics (debugging
ble.shitself) 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.shusessttycommand to set up the correct TTY settings for these user commands. Also, when the user invoked the command help functionality,manwill be executed.completionalso usesmanto 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):
awkfor fixing buggy output ofdeclare -pof 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:
ttyto obtain TTY name for PS1\l - (compat <= 4.1) util.sh (ble/util/strftime):
date - (compat <= 3.2) edit.sh:
grep,rm,mkfifoto 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,awkto show command help. - (user) complete.sh:
man,gzip,nroff,mkdirto extract and cache man information to generate completions - (diag) benchmark.sh (ble-measure):
awkto floating-point calculation - (diag) core-debug.sh (profiler):
grep,wc,awk,rm,sort - (diag) core-debug.sh (ble/debug/leakvar#list):
grep - (perf) decode.sh (ble/decode/nonblocking-read):
odwhen there are massive user inputs - (perf) history.sh:
awk,mv,sed,wcfor command history manipulations - (perf) core-complete.sh:
grep,sed,awk,sortfor manipulating the list of possible completions - (unused) util.sh (ble/util/getmtime):
date,stat[Note: this function is currently not used byble.shitself]