fix: finalize exited shell tasks and preserve command environments

This commit is contained in:
whyour
2026-09-29 00:52:33 +08:00
parent bc0f35e3f7
commit def4917447
4 changed files with 137 additions and 3 deletions
+3 -1
View File
@@ -84,7 +84,9 @@ env_str_to_array() {
}
clear_non_sh_env() {
if [[ $file_param != *.sh ]]; then
# Only automatic Node/Python preloads reconstruct the generated environment.
# Explicit interpreters and other commands must keep the shell-loaded values.
if [[ $isJsOrPythonFile == 'true' ]]; then
clear_env
fi
}
+7 -1
View File
@@ -18,6 +18,12 @@ single_hanle() {
exit 1
}
run_shell_script() {
# Preserve inherited variables/functions, but contain exit, exec and shell
# options so the task wrapper can run after hooks and report completion.
( . "$@" )
}
define_program() {
local file_param=$1
if [[ $file_param == *.js ]] || [[ $file_param == *.mjs ]]; then
@@ -25,7 +31,7 @@ define_program() {
elif [[ $file_param == *.py ]] || [[ $file_param == *.pyc ]]; then
which_program="python3"
elif [[ $file_param == *.sh ]]; then
which_program="."
which_program="run_shell_script"
elif [[ $file_param == *.ts ]]; then
which_program="ts-node-transpile-only"
else