Skip to content

docs: explain unmatched Bash glob behavior - #12

Merged
posidoni merged 3 commits into
posidoni:mainfrom
cnYui:docs/bash-nullglob-empty-match
Jul 14, 2026
Merged

docs: explain unmatched Bash glob behavior#12
posidoni merged 3 commits into
posidoni:mainfrom
cnYui:docs/bash-nullglob-empty-match

Conversation

@cnYui

@cnYui cnYui commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a safe runnable pair showing the default unmatched-glob behavior and the nullglob fix
  • document nullglob and failglob in the Bash reference
  • list the new example pair in the Bash examples index

Closes #9.

Validation

  • task ci
  • task hooks
  • git diff --check
  • direct example run: bad prints found: *.txt; good prints matched 0 file(s)

@cnYui
cnYui requested a review from posidoni as a code owner July 12, 2026 21:15

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Bash example demonstrating the use of nullglob to handle empty glob matches, along with corresponding documentation updates in the README and reference guide. The feedback highlights a compatibility issue with Bash 3.2 (default on macOS) where EXIT traps defined inside subshell functions do not trigger, resulting in temporary directory leaks. It is recommended to move the temporary directory creation and trap definitions to the global scope.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread examples/bash/04-nullglob-empty-match.bad.sh
Comment thread examples/bash/04-nullglob-empty-match.good.sh
@cnYui

cnYui commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in e2e48f6. The temporary directory and EXIT trap now live at script scope, so cleanup is not tied to the main subshell on Bash 3.2. Verified locally with bash -n, an isolated TMPDIR cleanup check, and git diff --check. I could not run task ci locally because the required Task/ShellCheck/shfmt/bats toolchain is unavailable in this environment.

@posidoni

Copy link
Copy Markdown
Owner

Thank you for your contribution. I will review it carefully and come back with my feedback soon.

@posidoni posidoni added the enhancement New feature or request label Jul 14, 2026

@posidoni posidoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for this — closes #9 exactly per the contract in CONTRIBUTING.md, and the reference/bash.md addition on nullglob/failglob is accurate and well cited. CI is green on all four required checks.

Nit: examples/bash/04-nullglob-empty-match.bad.sh still defines the mktemp/trap EXIT pair inside the main() ( ... ) subshell (as gemini-code-assist flagged). Under Bash 3.2 — which macOS ships by default and which this repo's shell-macos CI job targets — an EXIT trap set inside a subshell doesn't fire when the subshell exits, so the temp dir leaks. .good.sh already has the fix (trap hoisted to global scope); .bad.sh just needs the same move. This is a portability nit, not a blocker — approving as-is and I'll track it in a small follow-up issue/PR rather than hold this up.

Merging now. Thanks for picking this up!

@posidoni
posidoni merged commit a842048 into posidoni:main Jul 14, 2026
4 checks passed
@posidoni

Copy link
Copy Markdown
Owner

Merged — thank you for the contribution, @cnYui! Nice work on the nullglob write-up and example pair. Appreciate you taking the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document the nullglob / empty-glob pitfall in the bash domain

2 participants