aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
Diffstat (limited to 'toys')
-rw-r--r--toys/pending/sh.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 797b96a3..4c3735d7 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -1417,10 +1417,10 @@ static int expand_arg(struct sh_arg *arg, char *old, unsigned flags,
if (!bnext || bb->cnt<0 || bnext->commas[0]>bb->commas[bb->idx+1]) {
// output uninterrupted span
- if (bb->cnt<0)
- s += sprintf(s, (bb->cnt==-1) ? "%c" : "%d",
- bb->commas[2]+bb->commas[4]*bb->idx);
- else {
+ if (bb->cnt<0) {
+ k = bb->commas[2]+bb->commas[4]*bb->idx;
+ s += sprintf(s, (bb->cnt==-1) ? "\\%c"+!ispunct(k) : "%d", k);
+ } else {
i = bb->commas[bstk->idx]+1;
s = stpncpy(s, old+i, bb->commas[bb->idx+1]-i);
}