Skip to content

Latest commit

 

History

History
59 lines (49 loc) · 1.48 KB

File metadata and controls

59 lines (49 loc) · 1.48 KB

command logo

command() Function

What is command()?

  • 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:

Philosophy / History

While developing my project pacostrap, I realized:

  • system() is too risky due to shell injection.
  • fork() and exec() are safe, but painful to read and write.

So I wrote my own wrapper — command() — a minimal, readable and safe way to execute commands.

Example Usage

#include <command.hpp> // for my own super duper awesome command function

int main() {
    command("ls");
    return 0;
}

Compiling library

make
sudo make install

Compiling your own code with library

g++ main.cpp -lcommand -o main.elf

Running

./main.elf

Uninstalling library

sudo make uninstall

Licensing

This 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