command()is a small but powerful FOSS C++ function.- Its formula is basically: system()-like syntax + fork()/exec() safety = command()
- Designed to provide an easy, readable, shell-free way to run system commands.i
- It is single .hpp file function, so it is very easy for adding it to your C++ project:
While developing my project pacostrap, I realized:
system()is too risky due to shell injection.fork()andexec()are safe, but painful to read and write.
So I wrote my own wrapper — command() — a minimal, readable and safe way to execute commands.
#include <command.hpp> // for my own super duper awesome command function
int main() {
command("ls");
return 0;
}make
sudo make installg++ main.cpp -lcommand -o main.elf./main.elfsudo make uninstallThis project is licensed under the GNU Affero General Public License v3 (AGPLv3). Allowed License Reuse: You may reuse this function in projects that are licensed under copyleft (strong or weak) licenses, such as:
- GNU GPLv2, GPLv3, AGPLv3, LGPLv2, LGPLv3
- SSPL
- EUPL
- CeCILL v2.1
- OSL
- RTPL
- MPL For more detail, please look at LICENSE file
