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 she开发者_运维百科ll 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?
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.
精彩评论