system_nosh(3)

✨ system_nosh ✨ (3)

okay bestie, so this is a page from the Linux Programmer's Manual, and it's literally about running commands without a shell. no shell, no problem, we're doing this the direct way πŸ’…


🌸 NAME 🌸

esystem, system_eexecsp β€” execute a command with its arguments from a string without using a shell 🐚🚫


πŸŽ€ SYNOPSIS πŸŽ€

#include <stdlib.h>
#include <execs.h>

int esystem(const char *command);
int system_eexecsp(const char *command);

so like, these functions? they're provided by libexecs and libeexecs β€” you gotta link with -lexecs or -leexecs. no cap, that's the whole vibe check for linking 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

esystem is almost a drop in replacement for system(3) from the libc. key word: almost. the way it works is, esystem parses that command string and runs the command directly, without ever touching a shell. iconic behaviour honestly πŸ‘‘

also psa: system_eexecsp and esystem are synonyms. same function, different name, they're giving twin energy fr fr.

so how does it split up your command arguments? command arguments in args are delimited by space characters β€” and by that we mean blanks, tabs, or new lines, all of them count πŸ’«

and you can quote things! single or double quotes can be used to delimitate command arguments including spaces, and a non quoted backslash (\) is the escape character that protects the next char. so like, backslash is the bodyguard of whatever character comes next πŸ›‘οΈ

the executable file gets sought using the PATH environment variable, exactly as explained for execlp(3). so PATH does the finding, you do the vibing 🌈


πŸ’– RETURN VALUE πŸ’–

these functions have the same return values as system(3). that's it, that's the section, matching energy only πŸ’…


πŸ“ EXAMPLE πŸ“

here's a little program showing off the usage of esystem:

#include <stdio.h>
#include <unistd.h>
#include <execs.h>

#define BUFLEN 1024
int main(int argc, char *argv)
{
     char buf[BUFLEN];
     printf("type in a command and its arguments, e.g. 'ls -l'\n");
     while (fgets(buf, BUFLEN, stdin) != NULL) {
          printf("Command: '%s' \n",buf);
          esystem(buf);
          printf("Command done\n");
     }
}

like?? it literally prompts you, reads your command, runs it, says "Command done". main character loop energy πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

(that last one is literally the page you're reading rn, meta moment πŸ™ˆ)


πŸ’€ BUGS πŸ’€

found a bug? bug reports should be addressed to <info@virtualsquare.org> β€” slide into their inbox bestie, they wanna hear it πŸ“¬


🧚 AUTHOR 🧚

Renzo Davoli <renzo@cs.unibo.it> β€” thank you for your service king 🫢


VirtualSquare, 2014-05-27, and yeah the man page signs itself system_nosh(3) at the bottom, which is very "I contain multitudes" of it ✨ mwah, take care of your processes, drink water, and never use a shell when you don't have to πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from