









I would go further. There is way too much use of the shell to do things that you could just as easily do by hand. In my book, there are only two legitimate reasons to invoke the shell:
* You are implementing a launcher or the like, and passing a user-input command line directly to the shell with little or no modification.
* You are executing a shell script (possibly one that you wrote), and that shell script has gone through the usual linters (shellcheck and whatnot).
The following cases are not legitimate:
* system(3) is more convenient than fork(2)/execlp(3) (get over it and write the extra 5-10 lines of code).
* You have some convoluted command line and don't want to do it all by hand (write a very short shell script instead).
* Nobody told you that execlp(3) exists, and you're just following what the LLM says (I'm willing to forgive this, but not excuse it - please educate yourself before you write code that will be used by other people).
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。