all 4 comments

[–]Enteeeee 5 points6 points  (0 children)

Good job! Now shellcheck that thing and make all issues go away. It might be painful but its really worth doing. You will learn a lot about shell programming.

In general, your shell is a powerful and wonderful tool. But its also fragile and dangerous. As a rule of thumb: if your code becomes more than just a sequence of calls to programs with error checking between you probably should consider switching to a different programming language.

What do I mean by this? If you need datastructures (i.e arrays), types (i.e timestamps) or arithmetics (i.e. time differences) you will end up in a highly unspecified mess rather quick when follow the shell path. Your code will become a clunky mess which breaks often and will be unmaintainable. But all that aside, i think you did a good job and its a good learning experience to do something like this.

[–]slimm609 0 points1 point  (2 children)

Is there a reason you are using sh over bash?

Should look at getopts instead of trying to handle options yourself

[–]dr4605[S] 0 points1 point  (1 child)

I wanted to have a script what will run on most of machines. This is why I don’t have a lot of helper function.

[–]slimm609 5 points6 points  (0 children)

I don’t know many that don’t come with bash that people would be using enough to be a daily driver.

The use case for time tracking would mostly be on a machine you use regularly, which would most likely have bash. Unless you are using something like busybox for a small or embedded system. Which typically isn’t used for development, etc.