News for hackers. Stuff that matters.
Re:How to write idempotent Bash scripts by intc on Sunday July 07, 2019 @11:20AM (#20375511)
> This is an easy one. Touch is by default idempotent. This means you can call it multiple times without any issues. A second call won’t have any effects

Every call to touch will alter the modification time of the file (example.txt in this case).

Re:How to write idempotent Bash scripts by jrumbut on Sunday July 07, 2019 @11:28AM (#20375556)
It will change the access time too. Almost every suggestion in the post has this problem which is unfortunate since access/modify/create time are used in a lot of scripts to see which files were or were not processed by prior runs of a script (whether this is a good idea or not).

It is very difficult to write truly idempotent bash scripts (consider log files). Creating sort of idempotent or at least rerunnable scripts would be nice but I think even that would take more care than this.

Re:How to write idempotent Bash scripts by theamk on Tuesday July 09, 2019 @02:01AM (#20389330)
Do people actually use access time for anything?

I occasionally do full-text searches on system files, and this resets access times on all files. Thus, I cannot imagine using a script which cares about it.