Skip to content

fix: expand leading ~ in path flags and profiles#48

Merged
Caedis merged 1 commit into
masterfrom
caedis/fix-tilde-expansion
May 24, 2026
Merged

fix: expand leading ~ in path flags and profiles#48
Caedis merged 1 commit into
masterfrom
caedis/fix-tilde-expansion

Conversation

@Caedis

@Caedis Caedis commented May 24, 2026

Copy link
Copy Markdown
Owner

Problem

Quoted "~/path" arguments reach the program literally since the shell only expands an unquoted ~. The literal ~ was then joined relative to cwd, producing broken paths like /home/user/~/....

Fix

  • internal/paths/expand.go - new ExpandTilde(). Expands leading ~ / ~/... to home dir. Leaves ~user, mid-path ~, and relative paths alone.
  • cmd/root.go - expandFlagPaths() in PersistentPreRunE expands instance-dir, log-file, cache-dir, and the update-all cache flag.
  • internal/profile/profile.go - Load() expands stored instance-dir/cache-dir/log-file (covers update-all per-profile paths).

Tests

Written test-first (TDD). Cover the helper, profile load, and flag wiring. Full suite + go vet + gofmt clean. Verified end-to-end: --instance-dir "~/inst" loads state from $HOME/inst.

Closes #46

Quoted "~/path" args reach the program literally since the shell only
expands an unquoted ~. The literal ~ was then joined relative to cwd,
producing paths like /home/user/~/... that fail to resolve.

Closes #46
@Caedis Caedis merged commit 30fe5a1 into master May 24, 2026
1 check passed
@Caedis Caedis deleted the caedis/fix-tilde-expansion branch May 24, 2026 22:28
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.

[linux-amd64] ~ expansion seems broken

1 participant