sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

D1867.recursiveTrapWA-stub.patch (3612B)


      1 From d644e30a2024f729494cdff00891797576f03801 Mon Sep 17 00:00:00 2001
      2 From: Koichi Murase <myoga.murase@gmail.com>
      3 Date: Mon, 29 Aug 2022 11:34:53 +0900
      4 Subject: [PATCH] [stub] recursive trap wa: (implA) array postproc
      5 
      6 ---
      7  src/util.hook.sh | 31 +++++++++++++++++--------------
      8  1 file changed, 17 insertions(+), 14 deletions(-)
      9 
     10 diff --git a/src/util.hook.sh b/src/util.hook.sh
     11 index b88d004..be80b29 100644
     12 --- a/src/util.hook.sh
     13 +++ b/src/util.hook.sh
     14 @@ -293,7 +293,6 @@ function blehook/eval-after-load {
     15  # blehook
     16  
     17  _ble_builtin_trap_inside=  # ble/builtin/trap 処理中かどうか
     18 -_ble_builtin_trap_processing= # ble/buitlin/trap/.handler 実行中かどうか
     19  
     20  ## @fn ble/builtin/trap/.read-arguments args...
     21  ##   @var[out] flags
     22 @@ -815,6 +814,15 @@ function ble/builtin/trap/invoke {
     23    return 0
     24  } 3>&2 2>/dev/null # set -x 対策 #D0930
     25  
     26 +_ble_builtin_trap_processing= # ble/buitlin/trap/.handler 実行中かどうか
     27 +_ble_builtin_trap_depth=0
     28 +_ble_builtin_trap_postproc=()
     29 +_ble_builtin_trap_lastarg=()
     30 +function ble/builtin/trap/install-hook/.compose-trap_command {
     31 +  local sig=$1 name=${_ble_builtin_trap_sig_name[$1]}
     32 +  local handler='ble/builtin/trap/.handler SIGNUM "$BASH_COMMAND" "$@"; builtin eval -- "${_ble_builtin_trap_xpostproc[_ble_builtin_trap_depth]}" \# "${_ble_builtin_trap_xlastarg[_ble_builtin_trap_depth]}"'
     33 +  trap_command="trap -- '${handler/SIGNUM/$sig}' $name"
     34 +}
     35  ## @fn ble/builtin/trap/.handler sig bash_command params...
     36  ##   @param[in] sig
     37  ##     Specifies the signal number
     38 @@ -822,8 +830,9 @@ function ble/builtin/trap/invoke {
     39  ##     Specifies the value of BASH_COMMAND in the original context
     40  ##   @param[in] params...
     41  ##     Specifies the positional parameters in the original context
     42 -##   @var[out] _ble_builtin_trap_postproc
     43 -##   @var[out] _ble_builtin_trap_lastarg
     44 +##   @var[in] _ble_builtin_trap_depth
     45 +##   @var[out] _ble_builtin_trap_xlastarg[_ble_builtin_trap_depth]
     46 +##   @var[out] _ble_builtin_trap_xpostproc[_ble_builtin_trap_depth]
     47  function ble/builtin/trap/.handler {
     48    local _ble_trap_lastexit=$? _ble_trap_lastarg=$_ FUNCNEST= IFS=$_ble_term_IFS
     49    local set shopt; ble/base/.adjust-bash-options set shopt
     50 @@ -845,11 +854,8 @@ function ble/builtin/trap/.handler {
     51    shift 2
     52  
     53    local _ble_builtin_trap_processing=$_ble_trap_sig
     54 -
     55 -  # 透過 _ble_builtin_trap_postproc を設定
     56 -  local _ble_local_q=\' _ble_local_Q="'\''"
     57 -  _ble_builtin_trap_lastarg=$_ble_trap_lastarg
     58 -  _ble_builtin_trap_postproc="ble/util/setexit $_ble_trap_lastexit"
     59 +  local _ble_builtin_trap_lastarg=$_ble_trap_lastarg
     60 +  local _ble_builtin_trap_postproc="ble/util/setexit $_ble_trap_lastexit"
     61  
     62    # Note #D1782: ble/builtin/exit で "builtin exit ... &>/dev/null" と
     63    #   したリダイレクションを元に戻す。元々 builtin exit が出力するエラー
     64 @@ -915,12 +921,9 @@ function ble/builtin/trap/.handler {
     65    fi
     66  
     67    ble/base/.restore-bash-options set shopt
     68 -}
     69 -
     70 -function ble/builtin/trap/install-hook/.compose-trap_command {
     71 -  local sig=$1 name=${_ble_builtin_trap_sig_name[$1]}
     72 -  local handler="ble/builtin/trap/.handler $sig \"\$BASH_COMMAND\" \"\$@\"; builtin eval -- \"\$_ble_builtin_trap_postproc\" \\# \"\${_ble_builtin_trap_lastarg%%\$_ble_term_nl*}\""
     73 -  trap_command="trap -- '$handler' $name"
     74 +  local _ble_builtin_trap_depth=$((_ble_builtin_trap_depth+1))
     75 +  _ble_builtin_trap_xlastarg[_ble_builtin_trap_depth-1]=$_ble_builtin_trap_lastarg
     76 +  _ble_builtin_trap_xpostproc[_ble_builtin_trap_depth-1]=${_ble_builtin_trap_postproc%%$_ble_term_nl*}
     77  }
     78  
     79  ## @fn ble/builtin/trap/install-hook sig [opts]
     80 -- 
     81 2.37.2
     82