nameref, varnames, evalstring can unload loadables while they are being run

2023-11-27 Thread Emanuele Torre
I have notices that funsubs can be used to unload loadable builtins while they are being run e.g. bash-5.3$ enable -f {examples/loadables/,}mktemp bash-5.3$ declare -n foo='q[${| enable -d mktemp;}0]' bash-5.3$ mktemp -v foo /tmp/shtmp.jKcUE0 Segmentation fault (core dumped) T

[PATCH] OPTIND in funsub

2023-11-27 Thread Grisha Levit
If a funsub declares a local OPTIND, the calling context's getopts state gets messed up. For example, the following loop will not terminate: OPTIND=1; while getopts ab opt -ab; do echo $opt ${ local OPTIND; } done From f7f16f70cf0ef623541ff3b6a36cff10b4933914 Mon Sep 17 00:00:00 2

[PATCH] return at top-level after funsub

2023-11-27 Thread Grisha Levit
Calling `return' after a funsub outside of a function or `.' context doesn't behave correctly: $ bash -c '${ :; }; (return 2); echo $?' 2 $ bash -c '${ :; }; return' Segmentation fault From cd67d9defa0dbb7be36c1df163db33e78cac8f27 Mon Sep 17 00:00:00 2001 From: Grisha Levit Date: Tue, 28 Nov 202