Copying file to /dev/null

axricard axelrwiko at gmail.com
Fri Jan 24 09:57:05 UTC 2025


``` D
import std;

void main()
{
     auto sourceName = deleteme ~ "source";
     auto source = File(sourceName, "w");
     source.write("source");

     copy(sourceName, "/dev/null");
}
```

The copy to /dev/null fails : 
`std.file.FileException at std/file.d(4348): /dev/null: Invalid 
argument`, which is a little surprising. Why would it be an 
invalid argument ?


The cp command for example doesn't raise any error :

```
>> cp source /dev/null
>> echo $?
0
```


More information about the Digitalmars-d-learn mailing list