by ReDress · 1mo ago · 0 comments
Will this actually update the 'last modified' date for an already existing file?
Also, there's a standard way of processing command line arguments on Linux/Unix, which is not being followed here.
Major bug in the first command.
Technically, yes, it updates the last modified date, by actually emptying the file. He should have use "w+" or "a" instead of "w".
PS: I like this guy.
In natural language, this leads to semantic drift. In programming languages, semantic drift leads to bugs.
What I have never found any use for personally is opening a file in read-write mode, while also truncating it, which is the full extent of w+ behaviour. I cannot think of many reasons to have an output stream to also function as an input.
But, okay, that could make a valid excuse.
But, what you cannot excuse yourself for, is that you don't really add any functionality. In fact, you don't reproduce all the functionality let alone adding more.