bug: prevent tmux project listing from failing on empty roots#91
Open
ALX99 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
.local/bin/tmux-go-session --listfails when a configured project root exists but contains no child directories. Bash leaves the unmatched"$d"/*/pattern literal, and the script later tries to derive a tmux session name from the literal*basename.Severity and impact
This is a reliability bug in the tmux project picker. An empty project root is a normal state on a new machine, after moving projects, or when one of several configured roots is temporarily empty. Instead of continuing with existing tmux sessions and the built-in
~/dotfiles/~/.claudeentries, the picker exits non-zero and cannot open.Evidence
Relevant code on
master:.local/bin/tmux-go-session,emit_picker_rows()loops overfor sub in "$d"/*/without enablingnullglobor checking that each expanded value is a directory.$dis empty, Bash supplies the literal value$d/*/to the loop.${sub##*/}is*.*to_, strips the leading/trailing underscore, and produces an empty name.Cannot derive a tmux session name for project: <root>/*and returns 1.The added regression test creates an existing but empty project root, stubs
tmux list-sessions, runstmux-go-session --list, and verifies that listing succeeds without leaking the unmatched glob while preserving the built-in picker entries.This is a real defect rather than a hypothetical edge case because an existing empty directory deterministically triggers Bash's default unmatched-glob behavior.
Reproduce
Setup:
Triggering condition:
PROJ_DIRnames an existing directory with no child project directories.Exact command:
Actual result on
master:The command exits non-zero.
Expected result:
The command exits successfully, ignores the unmatched project glob, and continues listing valid session/project entries.
Reviewer regression command:
Root cause
The project enumeration loop assumes
"$d"/*/always expands to at least one real directory. Bash does not remove unmatched globs by default, so an empty root produces a literal glob string that is treated as a project path.Fix
Add a directory guard at the start of the inner loop:
This skips the unmatched literal and also defensively ignores any non-directory value without changing enumeration of real project directories.
Validation
Validation performed:
tmux-go-sessionempty-root/glob defect; no duplicate was found.<root>/*/-> basename*-> sanitized empty name -> existing error return.tests/tmux-go-session-empty-project-root.test.sh, which stubstmux, creates an empty project root, and asserts successful listing with no leaked glob.master...bug/tmux-go-session-empty-project-root: 2 commits ahead, 0 behind; only.local/bin/tmux-go-sessionand the focused regression test changed.Commands not run in this connector-only runtime:
No command output is claimed for those checks.
Scope
Intentionally not changed:
PROJ_DIR,~/dotfilesand~/.claudeentries,