![]() |
![]()
| ![]() |
![]()
NAMExt_parse_cmd() - Convert a command string to an argv-style array LIBRARY#include <xtend/proc.h> -lxtend SYNOPSISchar *xt_parse_cmd(char *argv[], int max_args, const char *cmd) ARGUMENTSargv: Pointer array to be filled with command tokens cmd: Raw command string with limited meta-character support from xt_strshellcpy(3) DESCRIPTIONBreaks a shell command into an argv[] style array suitable for xt_spawnvp() or execv*(). A copy of cmd is created using xt_strshellcpy(), which expands certain shell features such as variables and paths starting with '~'. The copy is then modified by replacing separators with '0' and the argv[] array is populated with pointers to each token in the copy. RETURN VALUESPointer to strdup() copy of cmd, which should be freed as soon as possible when argv[] is no longer needed. EXAMPLESchar *cmd, *argv[], *expanded_cmd; expanded_cmd = xt_parse_cmd(argv, cmd); xt_spawnvp(P_WAIT, P_NOECHO, argv, NULL, NULL, NULL); free(expanded_cmd); SEE ALSOxt_spawnvp(3), xt_spawnlp(3), exec(3)
|