A minimal commandline timer in C
make
timer [[-m minutes] [-s seconds] | [-t minutes:seconds]] [-hv]
-m minutes
number of minutes to count.
-s seconds
number of seconds to count.
-t minutes:seconds
timestring in minutes:seconds format
-h show help information
-v show version number
timer -m 2
timer -s 30
timer -t 2:30
- Use standard header for boolean
- Use block for
if
- Initialize every variable with value
- Use
unisigned int
for min and sec -
timer -t :
segfaults - Either
-s -m
or-t
flags - Make
clean
target.PHONY
- Streamline multiple exits
- Try to be platform independent (
unistd.h
) - Try to use safe versions of string functions
- Write comparisons in the way that left side is constant.
- const correctness on each function parameter and, if applicable, on variables