简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM