Conversation
| # Re-enable globbing. | ||
| set +f | ||
| # Re-set globbing to it's previous condition | ||
| $DIDGLOB && set +f |
There was a problem hiding this comment.
I wouldn't use && here as it confuses set -e environments in case $DIDGLOB is false. Another issue is this pollutes environment with variable DIDGLOB which might cause issues (either by overwriting an existing variable or by initializing it too early or whatsoever) - I know this is a general issue in sh apps, but I'd avoid it if possible or used trim_all()( ... ) instead of trim_all(){} or at least checked (set lists all currently set vars and function_names) whether the variable is already set or not.
Just my 2 cents 😉.
There was a problem hiding this comment.
It is simpler to understand, if you provide the example code. $DIDGLOB is also semi-terrible, because $DIDGLOB2 may also exist in nested contexts. Better use ${DIDGLOB}.
Currently, functions that need noglob set, always unset it before leaving the function, which can be problematic if it was set outside the function. This would fix that so that the noglob state is maintained in the caller.