Never change time/date stamp if file is not modified
Dos2Unix / Unix2Dos - Text file format converters
Brought to you by:
waterlan
It would be great if timestamps were untouched if the file is not modified.
I.e. the functionality activated with the option -k, --keepdate would always be activated if no changes are made to the target file.
The benefit would be e.g. possibility to run dos2unix on all sourcecode files in e.g. a commit hook script without triggering make to rebuild all files afterwards.
I can't see any potential drawbacks. Nobody wants to touch the timestamp on an untouched file.
Anonymous
Hi,
The change in the timestamp shows that the file has been processed. Similarly if you would run
, the timestamp of foo.txt will change even if there is no "aa" in foo.txt. The file did run through a filter, and it was replaced by the filter output. Ergo, the timestamp changes. I think this is expected behavior in Unix like environments.
What you could do is use the dos2unix -i option. Option -ic will make dos2unix print only the files that would be converted. This command will leave files without dos line breaks untouched:
This command will find C files that have dos line breaks:
You can use the output for another xargs that runs dos2unix.
I see no problem in using the -k option. Changing line breaks doesn't change the compiler output, there is never a need to rebuild.
Last edit: Erwin Waterlander 2022-11-11