aboutsummaryrefslogtreecommitdiff
path: root/chad/qx.h
blob: 817eaffa87bd8f85d6538e8fc4fda4cf01b639e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef QX_H
#define QX_H

#ifdef __cplusplus
extern "C" {
#endif

/* # qx
 *
 * ## NAME
 * qx - execute system commands receive back the output
 *
 * ## SYNOPSIS
 */
extern char * qx(const char * const cmd);
/* ## DESCRIPTION
 * `qx()` is a small wrapper function to replicate Perl's `qx` in C.
 * It is intended for developer convenience.
 * The command argument is a pointer to a null-terminated
 * string containing a shell command line.
 * This command is passed to `/bin/sh` using the `-c` flag; interpretation,
 * if  any,  is  performed by the shell.
 *
 * ## RETURN VALUE
 * Upon successful return, the captured `stdout` and `stderr` of `cmd` is returned
 * in a dynamic string. Calling `free()` is the programmer's responsibility.
 *
 * If an error is encountered `NULL` is returned.
 * The shell returning a non-zero exit value is not considered an error.
 */

#ifdef __cplusplus
}
#endif

#endif