Roman A. Taycher
Roman A. Taycher

Reputation: 19477

Calling shell scripts vs c functions

Certain small tasks seem to be much easier to accomplish via shell script then writing a small version of the utility that doesn't necessarily handle all edge cases in c(especially when a problem seems to fit the unix pipe/filter style).

On the other hand embedding shell calls in c code seem ugly. Assuming fairly basic utilities/options(such as busybox) and not much need for portability what is a good rule of thumb?

Upvotes: 0

Views: 241

Answers (1)

R.. GitHub STOP HELPING ICE
R.. GitHub STOP HELPING ICE

Reputation: 215261

Even just calling and communicating with an external program from C has a lot more corner cases and difficult-to-get-right issues than doing the task in C. It will also easily be as much as 100 times slower, and maybe worse. If you find yourself wanting to use shell utilities from C, then C is probably not the right language for you.

Upvotes: 1

Related Questions