Skip to content

fix(vfs): handle ./ prefix in path resolution#1142

Merged
chaliy merged 1 commit intomainfrom
fix/issue-1114-dot-prefix
Apr 7, 2026
Merged

fix(vfs): handle ./ prefix in path resolution#1142
chaliy merged 1 commit intomainfrom
fix/issue-1114-dot-prefix

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 7, 2026

Summary

  • Normalize . and .. path components in Interpreter::resolve_path, glob directory resolution, and PosixFs methods
  • Ensures ./filename resolves identically to filename relative to cwd across all VFS operations (ls, cat, redirections, test builtin, globs)

Changes

  • Interpreter::resolve_path: Now calls normalize_path on the joined result, fixing redirections (> ./file), script execution (./script.sh), and the test builtin ([ -f ./file ])
  • Interpreter test-command lambda: Same normalization for inline path resolution in [/test
  • glob::expand_glob: Normalizes the directory path when pattern has a relative prefix like ./
  • PosixFs: All FileSystem trait methods now normalize input paths before delegating to the backend, ensuring custom FsBackend implementations work correctly with . and .. components

Test plan

  • test_dot_slash_prefix_lsls ./file works
  • test_dot_slash_prefix_globecho ./*.html works
  • test_dot_slash_prefix_catcat ./file works
  • test_dot_slash_prefix_redirectecho x > ./file works
  • test_dot_slash_prefix_test_builtintest -f ./file works
  • test_posix_normalize_dot_slash_prefix — PosixFs handles ./ paths
  • test_posix_normalize_preserves_semantics — parent-exists checks still work
  • All 2036 existing tests pass

Closes #1114

Normalize paths with `.` and `..` components in:
- Interpreter::resolve_path (used by redirections, test builtin, script exec)
- Interpreter test-command inline resolve lambda
- Glob expand_glob directory resolution
- PosixFs (all FileSystem trait methods)

Closes #1114
@chaliy chaliy merged commit 8dc37b3 into main Apr 7, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-1114-dot-prefix branch April 7, 2026 05:52
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.

fix(vfs): paths with ./ prefix fail to resolve in glob and file operations

1 participant