Skip to content

Make wildcard expansion POSIX-compliant: exclude dotfiles by default#306

Merged
Stasshe merged 7 commits intomainfrom
copilot/remove-gitignore-from-wildcard
Feb 1, 2026
Merged

Make wildcard expansion POSIX-compliant: exclude dotfiles by default#306
Stasshe merged 7 commits intomainfrom
copilot/remove-gitignore-from-wildcard

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

Wildcard patterns (*, ?) were matching dotfiles (.gitignore, .env, etc.), causing unintended deletions via rm * and similar commands. This violates POSIX conventions where wildcards explicitly exclude files starting with ..

Changes

Wildcard expansion logic (base.ts, expansion.ts)

  • Added dotfile filter: skip files starting with . unless pattern explicitly starts with .
  • Applied to expandPathRecursive(), expandGlob(), and globExpand()
// Check if pattern explicitly targets dotfiles
const patternExplicitlyMatchesDotfiles = pattern.startsWith('.');

// Skip dotfiles unless explicitly matched
if (fileName.startsWith('.') && !patternExplicitlyMatchesDotfiles) {
  continue;
}

Behavior

  • rm * → matches file.txt but not .gitignore
  • rm .* → matches .gitignore
  • rm .gitignore → matches .gitignore
  • ls ? → matches a but not .

Impact

Breaking change. Aligns with standard Unix shell behavior (bash, zsh, sh). Prevents accidental deletion of configuration files.

Tests

  • Unit tests for wildcard expansion with dotfiles
  • Unit tests for git status parsing of deleted dotfiles
  • Manual test scenarios documented
Original prompt

rm -rf *のようなワイルドカードに.gitignoreは入るべきでない。また、.gitignoreや.始まりのファイルを消したときgitpanelに表示されないし、処理できない。


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Co-authored-by: Stasshe <133995608+Stasshe@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove .gitignore from wildcard deletion Make wildcard expansion POSIX-compliant: exclude dotfiles by default Feb 1, 2026
Copilot AI requested a review from Stasshe February 1, 2026 07:22
@Stasshe Stasshe marked this pull request as ready for review February 1, 2026 07:30
@Stasshe Stasshe temporarily deployed to copilot/remove-gitignore-from-wildcard - pyxis-code PR #306 February 1, 2026 07:30 — with Render Destroyed
@Stasshe Stasshe temporarily deployed to copilot/remove-gitignore-from-wildcard - pyxis-code PR #306 February 1, 2026 07:31 — with Render Destroyed
@Stasshe Stasshe merged commit 881665d into main Feb 1, 2026
@Stasshe Stasshe deleted the copilot/remove-gitignore-from-wildcard branch February 1, 2026 07:31
@Stasshe Stasshe mentioned this pull request Feb 5, 2026
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.

2 participants