4 /* Help to copy the thing properly quoted for the shell safety.
5 * any single quote is replaced with '\'', any exclamation point
6 * is replaced with '\!', and the whole thing is enclosed in a
9 * original sq_quote result
10 * name ==> name ==> 'name'
11 * a b ==> a b ==> 'a b'
12 * a'b ==> a'\''b ==> 'a'\''b'
13 * a!b ==> a'\!'b ==> 'a'\!'b'
15 #define EMIT(x) ( (++len < n) && (*bp++ = (x)) )
17 size_t sq_quote_buf(char *dst
, size_t n
, const char *src
)
24 while ((c
= *src
++)) {
25 if (c
== '\'' || c
== '!') {
42 char *sq_quote(const char *src
)
47 cnt
= sq_quote_buf(NULL
, 0, src
) + 1;
49 sq_quote_buf(buf
, cnt
, src
);