Syntax
Description
Thetouch command creates empty files in Nash’s virtual filesystem. If a file already exists, the command succeeds silently without modifying the file (unlike Unix touch, which updates timestamps).
Nash’s
touch is a simplified version that only creates empty files. It doesn’t update timestamps because the VFS doesn’t track file modification times.Parameters
One or more file paths to create. Can be relative or absolute. Supports multiple files in a single command.
Behavior
- Creates empty files: New files are created with zero bytes
- Multiple files: Can create multiple files in one command
- Existing files: If file exists, no error is raised (idempotent)
- Flag handling: Arguments starting with
-are silently ignored - No output: Success produces no output (silent operation)
Examples
Create a single file
Create multiple files
Create files in different directories
Create placeholder files
Create files with special names
Verify file creation
Create structure for a project
Error Handling
Parent directory doesn’t exist
Invalid path
Read-only filesystem
Implementation Details
- Source:
src/builtins/touch.rs - Uses
vfs.touch()to create files - Iterates through all non-flag arguments
- Arguments starting with
-are filtered out but not validated - No timestamp updates (VFS doesn’t track timestamps)
- Creates empty files (zero bytes)
Unlike Unix
touch, Nash’s version doesn’t support timestamp-related flags like -t, -d, -a, or -m because the VFS doesn’t maintain file timestamps.Differences from Unix touch
| Feature | Unix touch | Nash touch |
|---|---|---|
| Create empty file | ✅ Supported | ✅ Supported |
| Multiple files | ✅ Supported | ✅ Supported |
| Update access time | ✅ -a flag | ❌ No timestamps |
| Update modification time | ✅ -m flag | ❌ No timestamps |
| Set specific time | ✅ -t, -d | ❌ No timestamps |
| No-create mode | ✅ -c flag | ❌ Not supported |
| Reference file | ✅ -r flag | ❌ Not supported |
| Existing files | Updates time | No change |
Use Cases
Initialize project files
Create placeholder for later
Prepare test environment
Create configuration files
Batch file creation
Common Patterns
Create and immediately edit
Ensure file exists before operations
Create test fixtures
Initialize documentation structure
Working with Mount Points
Create files in mounted directory
./workspace/new_document.txt on the host system.
