Related: How Interactive Shells Work - https://github.com/akinomyoga/ble.sh
This is issue #653, in particular the list of tasks in this comment.
declare -p, etc.
declare, declare -p (#671)declare -f, type function ★trap, trap -pread -t timeout / builtin sleep #684trap -ldeclare -iluc and flags iluc in ${var@a}LC_CTYPE (or Binary manipulations) (#527 and #529)EPOCHREALTIME, SECONDS, and other dynamic variablesa=(declare v); "${a[@]}" failsexec non-existent-commandbind -x to get user input.\builtin local v=1 fails (Refs: Zulip)declare -p unset does not print any error messageIFS= eval 'local v=...'shopt -u expand_aliases fails and stops execution (fix 24146f4b)eval_unsafe_arith (#2263, Fix: #2268)builtin declare doesn't work (#654)mapfile -t stops reading the input with an empty line (#2287, fix 6431d76)declare -A d=([k]=v) (became irrelevant since InitializerList is implemented in #2279)${arr[@]::}
${var@a} with compat_array (Fix 9559c8ad)[ -c /dev/null ](--c-/dev/null-.html) fails in C++ version (fix #1618)osh -c 'read -d :' fails in the C++ osh (not in the Python osh) (Fix #1629)shopt -u expand_aliases fails in scripts sourced with arguments (Fix #1628)c84c4054)c26d3202)435acd16)c3eee5fd)read -t 0 (Or select/poll-like feature)
select() on the terminal?mapfile / readarray ★ (tests #666)${arr[@]::0} prints all the elements: 2>/dev/null >&30 (Fix #723){fd}>&- does not close the fd (Fix #723)$((base#num)) are reversed${#BASH_SOURCE} and ${BASH_SOURCE:offset:length} count array elements.IFS= read -n 1 char disappearsdeclare -a arr removes existing arraysunset (#706 Tests #718) ★$ARRAY? ★ (Fix #728)$BASHPID (or Current subshell PID)1?a=1:1 (Ref #712)$ARRAY? ★ (Additional fix #733)printf %d \' for NULreturn 2>/dev/nulltype returntest -k (#649)((${prefix}a=${prefix}b)) (cf #644 #670) ★★unset -v 'a[0]' ★★[ -o emacs ](--o-emacs-.html) in interactive sessions ★
set +o emacs$FUNCNAME / $BASH_LINENO (#656)${*:offset} (#658)${!prefix@} self-rewrites (#657)declare -A dict=() (#661) ★★exec 5<> a.pipe (cf #223 #667 #672)exec {fd}> a.txt (cf #223 #672)exec 5>&- (cf #223 #667 #672)read -d '' (#356 #665) ★builtin readtrap -- ... / eval -- ... (#662) ★★printf '%()T' (cf #650 #668)${var=x}OIL_VERSION / OIL_VERSINFO? #683${arr[0]=x} (#660) ★${!prefix@} fails when prefix matches with an array name (daab1d6)${x/^} crashes (dbf9e00)declare -F funcname doesn't accept non-alphanumeric characters in funcname ★★ (ec62c8a)${var@a} (#689)rx in ${var@a} (14548dc)read fails on empty lines (#705) ★★Currently, ble.sh does not fully work on Oil. Only a part can be run for testing purpose.
$ git clone --recursive http://github.com/akinomyoga/ble.sh -b osh ble.osh
$ cd ble.osh
$ make
The branch osh is occasionally force-pushed so need to be forcibly updated by git reset --hard or git checkout -B. Please be careful not to have your own commits in osh branch or edits in the working tree before running the following commands. They will be lost. You need to save your changes in another branch.
$ cd ble.osh
$ git fetch origin
$ git checkout -B osh origin/osh
$ make
ble/util$ cd ble.osh
$ osh --rcfile oshrc.test-util
read -e by ble.shThe builtin read -e (read with line editor) is emulated by ble.sh. Minimal initialization for testing read -e is available with oshrc.read in osh branch of ble.sh.
$ cd ble.osh
$ osh --rcfile oshrc.read
$ read -e
Specify prompt (-p) and initial contents (-i):
$ read -e -p '[\u@\h \W]\$ ' -i 'echo hello'
Related: Running Package Builds with OSH