Skip to content

fix(cli): preserve percent signs in project roots - #92

Merged
ALX99 merged 2 commits into
masterfrom
bug/projselect-percent-root
Jul 20, 2026
Merged

fix(cli): preserve percent signs in project roots#92
ALX99 merged 2 commits into
masterfrom
bug/projselect-percent-root

Conversation

@ALX99

@ALX99 ALX99 commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Problem and impact

.local/bin/_projselect used the user-configurable PROJ_DIR value as part of printf’s format string. A valid project root containing a percent directive such as %s corrupted the selected path. For example, selecting alpha under projects%s produced projectsalpha/ instead of projects%s/alpha.

This breaks the project picker for legal Unix path names and can send callers to a path different from the one selected.

Reproduction and observed result

Validated against untouched master commit e784de73852fa5d7744a5ffffed7143567fe0748 using the exact parent script and temporary uname, find, and fzf stubs. The stubs reported Linux, emitted one project named alpha, and selected that row.

PATH="$tmp/bin:$PATH" PROJ_DIR="$tmp/projects%s" ./_projselect

Observed on the parent revision with GNU Bash 5.2.37:

status=0
stdout=/tmp/.../projectsalpha/
stderr=

Expected: /tmp/.../projects%s/alpha.

Root cause and fix

The parent implementation evaluated:

printf "$PROJ_DIR/%s\n" "$selection"

The %s embedded in PROJ_DIR became an additional conversion directive. The fix first captures the picker result, then uses a constant format string:

printf '%s/%s\n' "$PROJ_DIR" "$selection"

Both path components are now emitted literally. Discovery, preview, selection, and cancellation behavior are unchanged.

Validation commands and results

The same deterministic harness against the fixed file produced:

status=0
stdout=/tmp/.../projects%s/alpha
stderr=

Additional checks:

bash -n _projselect                         passed
shellcheck _projselect                     passed (ShellCheck 0.10.0)
git diff --check HEAD^...HEAD              passed
git diff --name-status HEAD^...HEAD        M .local/bin/_projselect

GitHub comparison reports the branch is one commit ahead of and zero commits behind current master, with only .local/bin/_projselect changed. The triggered Linter workflow passed.

A fresh shell clone was attempted but the runtime could not resolve github.com; repository reads and branch operations therefore used the GitHub integration. ShellCheck was installed through the configured internal Debian mirror.

Scope and risk

The branch contains one clean commit based on current master. It adds no tests, fixtures, temporary harnesses, generated files, dependency changes, or unrelated cleanup. The change is limited to safe output formatting after the existing picker completes.

@ALX99
ALX99 force-pushed the master branch 4 times, most recently from 7031eab to e784de7 Compare July 19, 2026 10:20
@ALX99
ALX99 marked this pull request as draft July 19, 2026 18:03
@ALX99
ALX99 force-pushed the bug/projselect-percent-root branch from 7eb7cd1 to dac1df6 Compare July 19, 2026 18:04
@ALX99 ALX99 changed the title bug: prevent project roots from corrupting selected paths fix(cli): preserve percent signs in project roots Jul 19, 2026
@ALX99
ALX99 marked this pull request as ready for review July 20, 2026 12:38
@ALX99
ALX99 merged commit 84f3695 into master Jul 20, 2026
4 checks passed
@ALX99
ALX99 deleted the bug/projselect-percent-root branch July 20, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant