Isn’t it just a bash script and bash is present and running anyway already?
But it doesn’t need to make sense to me that you would like to do it your way from scratch and in C.
Why not …
Have fun doing it!
It was only a rather rhetorical question and just my opinion.