This code is commented and should not require more than is already said.
Now, the essential enhancement I made since the sed era is the removal of all comments and correction of my code to remove all new lines.
I abandoned sed and went to Perl because sed does not support the non-greedy operator, which greatly simplified my work when removing delimited patterns (typically multiline comments).
Getting the full script
It is available on Github. Don’t hesitate to fork and make it better.
Note: the competition
There is none: this is not a tool I would recommend in production environment (for lack of test, for instance).
Why this script is good
It is a quick fix for simple and mostly static websites. It removes potentially sensitive information (many website have their .git repository deployed, containing everything in it, and comments can be a source of leak too, be it only be advertising the technology behind the scenes).
Why this script is bad
I needed something working quickly and without effort. This is it.
You can use it on your server to automatically deploy the latest version of your website. Imagine:
I am a consultant developer. This means I move from client to client and share their time constraints. This includes deadlines, but also work time.
It so happens that some clients have a time clock, like in the old days.
My problem is: while most of my client’s employees can see what the clock stores, I, as an extern, cannot. I do not like to be blind, so each time I am in this situation, like many people I know, I make an Excel sheet where I log my check-ins and -outs.
Sharing my timesheet…
On my latest mission, we were several on the team from the same company. I spent some days without my usual timesheet and when I grew tired, I sent my first basic version, with some conditional formatting, to all members there.
Since they did not seem very interested if I asked whether something standard was available, I did not expect much. But instead, I quickly got some feedback: they asked new features, signalled some bugs, …
The team grew, the requests followed. The possibilities of the timesheet were ever greater, and therefore so was its complexity.
… with the whole world
Finally, using e-mails to track the feedback and release the changelog and user manual became too heavy. I thought of a bug tracker. This led me to create a Github repository. The wiki would come in handy for the user manual too.
Thus the work on version 2, which should make the sheet less specific to our context and more widely usable, began.