diff --git a/memo/ChangeLog.md b/memo/ChangeLog.md index e3e40570..4d3045f9 100644 --- a/memo/ChangeLog.md +++ b/memo/ChangeLog.md @@ -22,7 +22,7 @@ - edit: support Bash 5.1 `READLINE_MARK` and `PROMPT_COMMANDS` `#D1328` e97a858 - syntax: support confusing parameter expansions like `${#@}`, etc. `#D1330` b7b42eb - contrib: add contrib for user settings `#D1335` f290115 -- syntax: support `${var@UuLK}` in Bash 5.1 `#D1336` 0000000 +- syntax: support `${var@UuLK}` in Bash 5.1 `#D1336` 04da4dd ## Changes @@ -80,6 +80,7 @@ - edit: fix a bug that `set +H` is cancelled on command execution `#D1332` 02bdf4e - syntax (`ble/syntax/parse/shift`): fix a bug of shift skip in nested words `#D1333` 65fbba0 - global: work around Bash-4.4 `return` in trap handlers `#D1334` aa09d15 +- util (`ble-stackdump`): fix a shift of line numbers `#D1337` 0000000 ## Compatibility diff --git a/memo/D1337.sh b/memo/D1337.sh new file mode 100644 index 00000000..8f52596c --- /dev/null +++ b/memo/D1337.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +f1() { + local message='hello world' + ble-stackdump "$message" +} + +f2() { + local dummy=1 + f1 + output=$dummy +} + +f3() { + local input=$1 output= + f2 + ret=$output +} + +f3 diff --git a/note.txt b/note.txt index 14d10519..fe1399ce 100644 --- a/note.txt +++ b/note.txt @@ -2915,6 +2915,11 @@ bash_tips 2020-04-19 + * ble-stackdump の開始フレームがずれている [#D1337] + ble/util/stackdump という内部実装に分けた為である。 + 分ける必要があっただろうか。或いは、開始フレームを外から変更できる様にする? + 後、BASH_LINENO の参照を誤っている。取り敢えず修正した。 + * syntax: 変数展開で bash-5.1 で UuLK という operator が追加されている [#D1336] というより、bash-4.3 では operator は無効にするべきでは。 →確かめてみた所ちゃんとその様な実装になっていた。 diff --git a/src/util.sh b/src/util.sh index 76248e73..7d125ebf 100644 --- a/src/util.sh +++ b/src/util.sh @@ -2742,14 +2742,15 @@ function ble-import { ## スタック情報の前に表示するタイトルを指定します。 ## _ble_util_stackdump_title=stackdump +_ble_util_stackdump_start= function ble/util/stackdump { ((bleopt_internal_stackdump_enabled)) || return 1 - local message=$1 - local i nl=$'\n' - local message="$_ble_term_sgr0$_ble_util_stackdump_title: $message$nl" - local iarg=$BASH_ARGC args= extdebug= + local message=$1 nl=$'\n' + message="$_ble_term_sgr0$_ble_util_stackdump_title: $message$nl" + local extdebug=1 iarg=$BASH_ARGC args= shopt -q extdebug 2>/dev/null && extdebug=1 - for ((i=1;i<${#FUNCNAME[*]};i++)); do + local i i0=${_ble_util_stackdump_start:-1} iN=${#FUNCNAME[*]} + for ((i=i0;i