diff --git a/ble-core.sh b/ble-core.sh index 3b668078..c59926c4 100644 --- a/ble-core.sh +++ b/ble-core.sh @@ -129,6 +129,9 @@ if ((_ble_bash>=40000)); then function ble/util/is-running-in-subshell { [[ $$ != $BASHPID ]]; } else function ble/util/is-running-in-subshell { + # Note: bash-4.3 以下では BASH_SUBSHELL はパイプやプロセス置換で増えないの + # で信頼性が低いらしい。唯、関数内で実行している限りは大丈夫なのかもしれ + # ない。 ((BASH_SUBSHELL)) && return 0 local bashpid= command='echo $PPID' ble/util/assign bashpid 'ble/bin/sh -c "$command"' @@ -658,19 +661,19 @@ function ble/util/declare-print-definitions { if (decl) { isArray = (decl ~ /declare +-[fFgilrtux]*[aA]/); - # bash-3.0 の declare -p は改行について誤った出力をする。 +#% # bash-3.0 の declare -p は改行について誤った出力をする。 if (_ble_bash < 30100) gsub(/\\\n/, "\n", decl); if (_ble_bash < 40000) { - # #D1238 bash-3.2 以前の declare -p は ^A, ^? を - # ^A^A, ^A^? と出力してしまうので補正する。 +#% # #D1238 bash-3.2 以前の declare -p は ^A, ^? を +#% # ^A^A, ^A^? と出力してしまうので補正する。 gsub(/\001\001/, "${_ble_term_SOH}", decl); gsub(/\001\177/, "${_ble_term_DEL}", decl); } if (flag_escape_cr) gsub(/\015/, "${_ble_term_CR}", decl); - # declare 除去 +#% # declare 除去 sub(/^declare +(-[-aAfFgilrtux]+ +)?(-- +)?/, "", decl); if (isArray) { if (decl ~ /^([[:alpha:]_][[:alnum:]_]*)='\''\(.*\)'\''$/) { diff --git a/ble-edit.sh b/ble-edit.sh index 280a036e..328f895d 100644 --- a/ble-edit.sh +++ b/ble-edit.sh @@ -5361,7 +5361,7 @@ else print "_ble_edit_history=(" } - # ※rcfile として読み込むと HISTTIMEFORMAT が ?? に化ける。 +#% # ※rcfile として読み込むと HISTTIMEFORMAT が ?? に化ける。 /^ *[0-9]+\*? +(__ble_ext__|\?\?)/ { if (n != "") { n = ""; @@ -5378,11 +5378,11 @@ else else gsub(apos, apos "\\" apos apos, line); - # 対策 #D1239: bash-3.2 以前では ^A, ^? が ^A^A, ^A^? に化ける +#% # 対策 #D1239: bash-3.2 以前では ^A, ^? が ^A^A, ^A^? に化ける gsub(/\001/, "'$apos'${_ble_term_SOH}'$apos'", line); gsub(/\177/, "'$apos'${_ble_term_DEL}'$apos'", line); - # 対策 #D1270: MSYS2 で ^M を代入すると消える +#% # 対策 #D1270: MSYS2 で ^M を代入すると消える gsub(/\015/, "'$apos'${_ble_term_CR}'$apos'", line); t = t != "" ? t "\n" line : line; @@ -5537,7 +5537,7 @@ function ble-edit/history/add { local command=$1 if [[ $_ble_edit_history_prefix ]]; then local code=' - # PREFIX_history_edit を未編集状態に戻す +#% # PREFIX_history_edit を未編集状態に戻す local index for index in "${!PREFIX_history_dirt[@]}"; do PREFIX_history_edit[index]=${PREFIX_history[index]} diff --git a/ble.pp b/ble.pp index 211a37d8..8d581dc9 100644 --- a/ble.pp +++ b/ble.pp @@ -62,6 +62,11 @@ return 1 2>/dev/null || exit 1 fi +if ((BASH_SUBSHELL)); then + builtin echo "ble.sh: ble.sh cannot be loaded into a subshell." >&2 + return 1 2>/dev/null || builtin exit 1 +fi + if [[ -o posix ]]; then unset _ble_bash echo "ble.sh: ble.sh is not intended to be used in bash POSIX modes (--posix)." >&2 diff --git a/test/benchmark/benchmark.sh b/test/benchmark/benchmark.sh index 41e1140b..4460dddf 100755 --- a/test/benchmark/benchmark.sh +++ b/test/benchmark/benchmark.sh @@ -68,6 +68,7 @@ _ble_measure_threshold=100000 # 一回の計測が threshold [usec] 以上にな ## @var[out] ret nsec function ble-measure { + local TIMEFORMAT= if [[ ! $_ble_measure_base ]]; then _ble_measure_base=0 nsec=0 # : よりも a=1 の方が速い様だ