From 2b39c39421648cdd65987934e5432d5a12d097b0 Mon Sep 17 00:00:00 2001 From: Emil Williams Date: Wed, 18 Feb 2026 00:56:45 +0000 Subject: should work without peru --- chad/qx.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 chad/qx.h (limited to 'chad/qx.h') diff --git a/chad/qx.h b/chad/qx.h new file mode 100644 index 0000000..817eaff --- /dev/null +++ b/chad/qx.h @@ -0,0 +1,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 -- cgit v1.2.3