quote empty strings for re-entry into shell
From: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
4abbaa0400
commit
0096aeeed4
11
misc.c
11
misc.c
|
@ -32,7 +32,7 @@
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.291 2018/01/14 00:03:03 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.292 2018/03/17 22:46:09 tg Exp $");
|
||||||
|
|
||||||
#define KSH_CHVT_FLAG
|
#define KSH_CHVT_FLAG
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
|
@ -1346,7 +1346,14 @@ print_value_quoted(struct shf *shf, const char *s)
|
||||||
const unsigned char *p = (const unsigned char *)s;
|
const unsigned char *p = (const unsigned char *)s;
|
||||||
bool inquote = true;
|
bool inquote = true;
|
||||||
|
|
||||||
/* first, check whether any quotes are needed */
|
/* first, special-case empty strings (for re-entrancy) */
|
||||||
|
if (!*s) {
|
||||||
|
shf_putc('\'', shf);
|
||||||
|
shf_putc('\'', shf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non-empty; check whether any quotes are needed */
|
||||||
while (rtt2asc(c = *p++) >= 32)
|
while (rtt2asc(c = *p++) >= 32)
|
||||||
if (ctype(c, C_QUOTE | C_SPC))
|
if (ctype(c, C_QUOTE | C_SPC))
|
||||||
inquote = false;
|
inquote = false;
|
||||||
|
|
Loading…
Reference in New Issue