Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Don't clobber NOGLOB in functions #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uberbaud
Copy link

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.

# Re-enable globbing.
set +f
# Re-set globbing to it's previous condition
$DIDGLOB && set +f
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😉.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants