--- sh.lex.c~ 2006-09-27 10:01:06.000000000 -0700 +++ sh.lex.c 2008-06-26 16:09:17.000000000 -0700 @@ -851,7 +851,8 @@ getsub(struct wordent *en) return (en); } slhs.len = 0; - Strbuf_append(&slhs, lhsb.s); + if (lhsb.s != NULL && lhsb.len != 0) + Strbuf_append(&slhs, lhsb.s); Strbuf_terminate(&slhs); if (exclc) en = dosub(sc, en, global);