mirror of
https://github.com/zdharma-continuum/zflai.git
synced 2026-09-10 07:06:16 -04:00
*_file_store,*_sqlite_store: Handle $(...) command substitution in hooks
This commit is contained in:
parent
0cf9428e62
commit
e557381e3d
|
|
@ -31,7 +31,7 @@ local -a splitted keys
|
|||
local first_key="${keys[1]}"
|
||||
[[ "$first_key" = *time* ]] && shift keys || coidx=0
|
||||
|
||||
[[ -n "${DB_DEFS[${__db}_<hooks>_on_open]}" ]] && builtin print -r -- "${DB_DEFS[${__db}_<hooks>_on_open]//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}" >>! "$__db_file"
|
||||
[[ -n "${DB_DEFS[${__db}_<hooks>_on_open]}" ]] && -zflai_subst_cmds "${DB_DEFS[${__db}_<hooks>_on_open]//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}" && builtin print -r -- "$REPLY" >>! "$__db_file"
|
||||
[[ -n "${DB_DEFS[${__db}_<hooks>_on_open_sh]}" ]] && ( builtin cd -q "${DB_DEFS[${__db}_<access>_path]}" && eval "${DB_DEFS[${__db}_<hooks>_on_open_sh]//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}"; )
|
||||
|
||||
for __it in "${(P)__array}"; do
|
||||
|
|
@ -55,7 +55,7 @@ for __it in "${(P)__array}"; do
|
|||
builtin print -r -- "$__text" >>! "$__db_file"
|
||||
done
|
||||
|
||||
[[ -n "${DB_DEFS[${__db}_<hooks>_on_close]}" ]] && builtin print -r -- "${DB_DEFS[${__db}_<hooks>_on_close]//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}" >>! "$__db_file"
|
||||
[[ -n "${DB_DEFS[${__db}_<hooks>_on_close]}" ]] && -zflai_subst_cmds "${DB_DEFS[${__db}_<hooks>_on_close]//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}" && builtin print -r -- "$REPLY" >>! "$__db_file"
|
||||
[[ -n "${DB_DEFS[${__db}_<hooks>_on_close_sh]}" ]] && ( builtin cd -q "${DB_DEFS[${__db}_<access>_path]}" && eval "${DB_DEFS[${__db}_<hooks>_on_close_sh]//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}"; )
|
||||
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ builtin print -r -p ".open ${__db_dir}/${__db_file}"
|
|||
local -a __hook_arr_out
|
||||
|
||||
[[ -n "${DB_DEFS[${__db}_<hooks>_on_open]}" ]] && {
|
||||
builtin print -r -p -- "${${DB_DEFS[${__db}_<hooks>_on_open]#(\!|@|\#)}//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}"
|
||||
-zflai_subst_cmds "${${DB_DEFS[${__db}_<hooks>_on_open]#(\!|@|\#)}//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}"
|
||||
builtin print -r -p -- "$REPLY"
|
||||
if [[ "${DB_DEFS[${__db}_<hooks>_on_open]}" = (\!|\#)* ]]; then
|
||||
-zflai_coproc_error_fetch SQLite 1 '__hook_arr_out[1]' ${${${(M)DB_DEFS[${__db}_<hooks>_on_open]#\!}:+get-tokens-nl}:-whitespace-collapse}
|
||||
elif [[ "${DB_DEFS[${__db}_<hooks>_on_open]}" = @* ]]; then
|
||||
|
|
@ -98,7 +99,8 @@ done
|
|||
__hook_arr_out=()
|
||||
|
||||
[[ -n "${DB_DEFS[${__db}_<hooks>_on_close]}" ]] && {
|
||||
builtin print -r -p -- "${${DB_DEFS[${__db}_<hooks>_on_close]#(\!|@|\#)}//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}"
|
||||
-zflai_subst_cmds "${${DB_DEFS[${__db}_<hooks>_on_close]#(\!|@|\#)}//(#m)${~_xchg_pat_}/${_xchg_map_[$MATCH]}}"
|
||||
builtin print -r -p -- "$REPLY"
|
||||
if [[ "${DB_DEFS[${__db}_<hooks>_on_close]}" = (\!|\#)* ]]; then
|
||||
-zflai_coproc_error_fetch SQLite 1 '__hook_arr_out[1]' ${${${(M)DB_DEFS[${__db}_<hooks>_on_close]#\!}:+get-tokens-nl}:-whitespace-collapse}
|
||||
elif [[ "${DB_DEFS[${__db}_<hooks>_on_close]}" = @* ]]; then
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ function -zflai_subst_cmds {
|
|||
|
||||
i=0
|
||||
REPLY="${(S)buffer//(#b)\$\((?#)([^\\]\))/${outputs[++i]}}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
typeset -g ZFLAI_LIBS_SOURCED=1
|
||||
|
|
|
|||
Loading…
Reference in a new issue