diff --git a/.gitignore b/.gitignore index 651d2e88..d5252c9c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,9 @@ # edit files /COMMIT -/[a-zA-Z].txt -/[a-zA-Z].sh +/[a-zA-Z0-9].txt +/[a-zA-Z0-9].sh +/\*scratch\* # test /test diff --git a/.srcoption b/.srcoption index 387c2973..dbf2dc95 100644 --- a/.srcoption +++ b/.srcoption @@ -1,2 +1,6 @@ --x md:bash --exclude=./out --exclude=./dist --exclude=./a.sh --exclude=./test/install --exclude=./ble.sh ble-syntax-ctx.def keymap/*.rlfunc.txt ble.pp blerc - +-x md:bash --exclude=./out --exclude=./dist --exclude=./a.sh --exclude=./test/install --exclude=./ble.sh +GNUmakefile +ble.pp +blerc +lib/core-syntax-ctx.def +lib/core-decode.*-rlfunc.txt diff --git a/GNUmakefile b/GNUmakefile index 8af87045..794e1dff 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -47,13 +47,8 @@ $(OUTDIR)/ble.sh: ble.pp GNUmakefile | $(OUTDIR) outdirs += $(OUTDIR)/keymap outfiles += $(OUTDIR)/keymap/emacs.sh outfiles += $(OUTDIR)/keymap/vi.sh $(OUTDIR)/keymap/vi_digraph.sh $(OUTDIR)/keymap/vi_digraph.txt $(OUTDIR)/keymap/vi_test.sh -outfiles += $(OUTDIR)/keymap/emacs.rlfunc.txt -outfiles += $(OUTDIR)/keymap/vi_imap.rlfunc.txt -outfiles += $(OUTDIR)/keymap/vi_nmap.rlfunc.txt $(OUTDIR)/keymap/%.sh: keymap/%.sh | $(OUTDIR)/keymap cp -p $< $@ -$(OUTDIR)/keymap/%.txt: keymap/%.txt | $(OUTDIR)/keymap - cp -p $< $@ #------------------------------------------------------------------------------ # lib @@ -67,6 +62,9 @@ outfiles += $(OUTDIR)/lib/core-complete.sh outfiles += $(OUTDIR)/lib/core-syntax.sh outfiles += $(OUTDIR)/lib/core-test.sh outfiles += $(OUTDIR)/lib/core-edit.ignoreeof-messages.txt +outfiles += $(OUTDIR)/lib/core-decode.emacs-rlfunc.txt +outfiles += $(OUTDIR)/lib/core-decode.vi_imap-rlfunc.txt +outfiles += $(OUTDIR)/lib/core-decode.vi_nmap-rlfunc.txt outfiles += $(OUTDIR)/lib/vim-surround.sh outfiles += $(OUTDIR)/lib/vim-arpeggio.sh outfiles += $(OUTDIR)/lib/test-main.sh diff --git a/ble.pp b/ble.pp index 454d047b..40e0375f 100644 --- a/ble.pp +++ b/ble.pp @@ -932,6 +932,7 @@ function ble/base/process-blesh-arguments { ble/util/print "ble.sh ($arg): an option argument is missing." >&2 fi ;; (--noinputrc) + _ble_builtin_bind_user_settings_loaded=noinputrc _ble_builtin_bind_inputrc_done=noinputrc ;; (--rcfile=*|--init-file=*|--rcfile|--init-file) if [[ $arg != *=* ]]; then diff --git a/keymap/vi.sh b/keymap/vi.sh index 95434e76..2d7a6162 100644 --- a/keymap/vi.sh +++ b/keymap/vi.sh @@ -5860,7 +5860,7 @@ function ble-decode/keymap:vi_nmap/define { # ble-bind -f '_' 'vi-rlfunc/yank-arg' } -# vi_nmap.rlfunc.txt 用 +# lib/core-decode.vi_nmap-rlfunc.txt 用 # d or D function ble/widget/vi-rlfunc/delete-to { diff --git a/keymap/emacs.rlfunc.txt b/lib/core-decode.emacs-rlfunc.txt similarity index 100% rename from keymap/emacs.rlfunc.txt rename to lib/core-decode.emacs-rlfunc.txt diff --git a/keymap/vi_imap.rlfunc.txt b/lib/core-decode.vi_imap-rlfunc.txt similarity index 100% rename from keymap/vi_imap.rlfunc.txt rename to lib/core-decode.vi_imap-rlfunc.txt diff --git a/keymap/vi_nmap.rlfunc.txt b/lib/core-decode.vi_nmap-rlfunc.txt similarity index 100% rename from keymap/vi_nmap.rlfunc.txt rename to lib/core-decode.vi_nmap-rlfunc.txt diff --git a/make_command.sh b/make_command.sh index d5488eb5..792cc5dd 100755 --- a/make_command.sh +++ b/make_command.sh @@ -632,7 +632,7 @@ function sub:check-readline-bindable { [[ $bash == bash-[12]* ]] && continue "$bash" -c 'bind -l' 2>/dev/null done | sort -u - ) <(sort keymap/emacs.rlfunc.txt) + ) <(sort lib/core-decode.emacs-rlfunc.txt) } #------------------------------------------------------------------------------ diff --git a/memo/ChangeLog.md b/memo/ChangeLog.md index 01ddb13e..cddf6f4f 100644 --- a/memo/ChangeLog.md +++ b/memo/ChangeLog.md @@ -75,6 +75,7 @@ - benchmark (`ble-measure`): support `-T TIME` and `-B TIME` option `#D1460` 1aa471b - util, color (`bleopt`, `blehook`, `ble-color-setface`): support `--color` and fix `sgr0` contamination in non-color output `#D1466` 69248ff - global: fix status check for read timeout `#D1467` e886883 +- decode: move `{keymap/*. => lib/core-decode.*-}rlfunc.txt` and clean up files `#D1486` e130619 # ble-0.4.0-devel2 diff --git a/memo/D1478.fix-rebind-C-x-test1.sh b/memo/D1478.fix-rebind-C-x-test1.sh new file mode 100644 index 00000000..5389d268 --- /dev/null +++ b/memo/D1478.fix-rebind-C-x-test1.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# unbind all "C-x ?" +for second in e g {A..Z} '\C-'{e,g,r,u,v,x,'?'} '!' '$' '(' ')' '*' '/' '@' '~'; do + bind -r '\C-x'"$second" +done + +bind -x '"\C-x\C-x":echo XX' +bind -r '\C-x\C-x' + +bind -x '"\C-x":echo X' +bind -x '"\C-b":echo B' diff --git a/memo/D1478.fix-rebind-C-x-test2.sh b/memo/D1478.fix-rebind-C-x-test2.sh new file mode 100644 index 00000000..f20f73b5 --- /dev/null +++ b/memo/D1478.fix-rebind-C-x-test2.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# unbind all "C-x ?" +for second in e g {A..Z} '\C-'{e,g,r,u,v,x,'?'} '!' '$' '(' ')' '*' '/' '@' '~'; do + bind -r '\C-x'"$second" +done + +# bash-4.2 以下で以下の様にすると vi で C-x を受信できなくなってしまう。 +bind -x '"\C-x\C-x":echo XX' +bind -r '\C-x\C-x' +set -o vi +bind -x '"\C-x":echo X' diff --git a/memo/D1483.check-rlfunc-decode-error.sh b/memo/D1483.check-rlfunc-decode-error.sh new file mode 100644 index 00000000..7cdb8038 --- /dev/null +++ b/memo/D1483.check-rlfunc-decode-error.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +echo "----------" +echo "locale" +locale + +echo "----------" +echo "test regex (default locale)" + +rex='^"([^\"]|\\.)*$' +[[ $'"\x9B": self-insert' =~ $rex ]] +echo "$? (${BASH_REMATCH[*]@Q})" + +echo "----------" +echo "test regex (locale C)" + +LC_ALL=C +[[ $'"\x9B": self-insert' =~ $rex ]] +echo "$? (${BASH_REMATCH[*]@Q})" diff --git a/memo/T0003.debug-trap.sh b/memo/T0003.debug-trap.sh new file mode 100644 index 00000000..1de36017 --- /dev/null +++ b/memo/T0003.debug-trap.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +bash44_traverse=1 + +function user-debug-handler { + local caller=${FUNCNAME[1]} + [[ $caller == ble-debug-handler ]] && + caller=${FUNCNAME[2]} + echo "trap($*):$caller: $BASH_COMMAND" +} + +# * 4.4 以降では最初に DEBUG を設定した関数呼び出しレベルを書き換える? +# 否、関数終了時に上書きする様にしたら良いという事の気がする。 +# * 関数を一つ上がったら trap handler を削除 +# * trap handler が全てなくなったら解除 +# ? yes: 内側の関数で活性化した時に外側の関数でもちゃんと DEBUG trap が発動 +# するのだろうか。 + +_debug_trap_handlers=() +function ble/trap-debug { + local depth=$((${#FUNCNAME[@]}-2)) + if [[ $1 != - ]]; then + _debug_trap_handlers[depth]=$1 + + # 再活性化 (extdebug/functrace が設定されていなければ、 + # 設定を行った関数呼び出しレベルでしか DEBUG trap は発生しない)。 + builtin trap ble-debug-handler DEBUG + else + unset '_debug_trap_handlers[depth]' + fi +} +function ble-debug-handler { + local depth=$((${#FUNCNAME[@]}-1)) + [[ $_ble_trap_suppress || ${FUNCNAME[1]} == trap ]] && return 0 + #echo "ble-debug-handler" + for ((;depth>=0;depth--)); do + local handler=${_debug_trap_handlers[depth]-} + [[ $handler ]] || continue + eval "$handler" + return "$?" + done +} +function ble-return-handler { + #echo "ble-return-handler" + local _ble_trap_suppress=1 + local depth=$((${#FUNCNAME[@]}-1)) + ((depth)) || return 0 + if [[ $bash44_traverse && ${_debug_trap_handlers[depth]+set} ]]; then + _debug_trap_handlers[depth-1]=${_debug_trap_handlers[depth]} + fi +} + +#------------------------------------------------------------------------------ + +function f3 { + builtin trap '_ble_trap_suppress=1 ble-return-handler' RETURN + trap 'user-debug-handler f3' DEBUG + echo f3 +} +function f2 { + builtin trap '_ble_trap_suppress=1 ble-return-handler' RETURN + echo f2:1 + f3 + echo f2:2 + trap - DEBUG +} +function f1 { + builtin trap '_ble_trap_suppress=1 ble-return-handler' RETURN + trap 'user-debug-handler f1' DEBUG + echo f1:1 + f2 + echo f1:3 + trap - DEBUG +} + +#------------------------------------------------------------------------------ + +#trap ble-debug-handler DEBUG + +# 通常 +f1 + +echo ---------- +trap ble-return-handler RETURN +function trap { local _ble_trap_suppress=1; ble/trap-debug "$1"; } +f1 diff --git a/memo/T0005.source-arguments-in-func.bashrc b/memo/T0005.source-arguments-in-func.bashrc new file mode 100644 index 00000000..5a97611a --- /dev/null +++ b/memo/T0005.source-arguments-in-func.bashrc @@ -0,0 +1,12 @@ +# bashrc -*- mode: sh-bash; -*- + +sub=T0005.source-arguments-in-func.source.sh + +function sourcer1 { source "$sub"; } +function sourcer2 { source "$sub" x; } + +sourcer1 A B C +sourcer2 A B C +shopt -s extdebug +sourcer1 A B C +sourcer2 A B C diff --git a/memo/T0005.source-arguments-in-func.source.sh b/memo/T0005.source-arguments-in-func.source.sh new file mode 100644 index 00000000..fc965529 --- /dev/null +++ b/memo/T0005.source-arguments-in-func.source.sh @@ -0,0 +1,17 @@ +# -*- mode: sh; mode: sh-bash -*- + +args=("$0" "$@") +declare -p args +declare -p FUNCNAME +declare -p BASH_LINENO +declare -p BASH_SOURCE +declare -p BASH_ARGC +declare -p BASH_ARGV + +# 呼び出しを行った後で extdebug を実行しても意味ない +# shopt -s extdebug +# declare -p BASH_ARGC +# declare -p BASH_ARGV +# shopt -u extdebug +echo ---------------------------------------- + diff --git a/memo/benchmark/array-access.sh b/memo/benchmark/array-access.sh new file mode 100644 index 00000000..d08326e0 --- /dev/null +++ b/memo/benchmark/array-access.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +if [[ ! $_ble_bash ]]; then + echo 'benchmark: Please source from a ble session.' >&2 + return 1 +fi + +function measure-array.1 { + local N=$1 + eval "local -a a=({1..$N})" + ble-measure "$2" +} +function measure-array { + measure-array.1 10 "$1 10 " + measure-array.1 100 "$1 100 " + measure-array.1 1000 "$1 1000 " + measure-array.1 10000 "$1 10000 " + measure-array.1 100000 "$1 100000" +} +function sum-forward { local s=0; for ((i=0;i=0;)); do ((s+=a[i])); done ; } +function sum-random { local s=0; for ((i=0;i