4 /* Help to copy the thing properly quoted for the shell safety.
5 * any single quote is replaced with '\'', and the caller is
6 * expected to enclose the result within a single quote pair.
9 * original sq_quote result
10 * name ==> name ==> 'name'
11 * a b ==> a b ==> 'a b'
12 * a'b ==> a'\''b ==> 'a'\''b'
14 char *sq_quote(const char *src)
16 static char *buf = NULL;
21 /* count bytes needed to store the quoted string. */
22 for (cnt = 3, cp = src; *cp; cnt++, cp++)
29 while ((c = *src++)) {
33 bp = strcpy(bp, "'\\''");