Bash tool creates NUL files on Windows, breaking OneDrive sync

Resolved 💬 3 comments Opened Dec 30, 2025 by kaidell-design Closed Jan 3, 2026

Bug Report: Bash tool creates NUL files on Windows, breaking OneDrive sync

Summary

When Claude Code runs Bash commands on Windows (using Git Bash), commands that redirect output to NUL create an actual file named "NUL" instead of redirecting to the Windows null device. This breaks OneDrive sync because "NUL" is a reserved Windows filename that OneDrive cannot process.

Environment

  • OS: Windows 11
  • Claude Code Version: Latest (as of 2025-12-30)
  • Shell: Git Bash (bundled with Git for Windows)

Steps to Reproduce

  1. Use Claude Code on Windows with OneDrive folder as working directory
  2. Run any command that includes output redirection to NUL, e.g.:
  • some_command 2>NUL
  • ping -n 1 127.0.0.1 > nul
  1. Observe that a file named "NUL" is created in the current directory
  2. OneDrive will report sync errors because "NUL" is a reserved Windows filename

Expected Behavior

Output redirected to NUL should go to the null device (be discarded), not create a file.

Actual Behavior

A file named "NUL" is created in the working directory. This file:

  • Cannot be synced by OneDrive (reserved name)
  • Cannot be easily deleted through normal Windows file operations
  • Requires special handling via \\?\ path prefix to delete

Root Cause

Git Bash on Windows doesn't recognize NUL as the Windows null device. It interprets > NUL as "redirect to a file named NUL".

The correct way to redirect to null in Git Bash is /dev/null, not NUL.

Suggested Fix

When Claude Code's Bash tool runs on Windows with Git Bash:

  1. Replace > NUL, 2> NUL, 2>NUL etc. with > /dev/null, 2> /dev/null in commands
  2. Or use Git Bash's /dev/null consistently instead of Windows-style NUL

Workaround

I've implemented a file system watcher that monitors for NUL file creation and deletes them immediately. This works but adds unnecessary overhead.

Impact

  • High for users with OneDrive/cloud sync: Sync completely stops until NUL files are manually deleted
  • Medium for other users: Spurious files created in working directories

Additional Context

This happens frequently during normal Claude Code usage, especially when commands involve error suppression or quiet modes that redirect to null.

---

To submit: Go to https://github.com/anthropics/claude-code/issues and create a new issue with this content.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗