Richard Ulmer writes: > Hi, > when there is a single ' in a comment within a subshell, I get this > error: foo[6]: no closing quote > > Here is an example script to reproduce the problem: > > foo=$( > # It's bar: > echo bar > ) > echo $foo
This is certainly not the best way to do this but it does the job: ~/src/ksh [OpenBSD 6.6] [ksh]flask@void$ /bin/ksh void$ foo=$( > # quote: ' > echo bar > ) > ^D /bin/ksh: no closing quote ~/src/ksh [OpenBSD 6.6] [ksh]flask@void$ ./ksh void$ foo=$( > # quote: ' > echo bar > ) void$ echo $foo bar void$ In particular it just reeks of kludge, which I'm not happy with because according to the comment two-dozen lines up it's already a kludge. The loop is lifted from the beginning of the same function, where regular comments are skipped. Matthew --- lex.c.~1.78.~ Mon Jan 15 16:58:05 2018 +++ lex.c Sat Dec 14 10:55:06 2019 @@ -496,6 +496,12 @@ statep->ls_scsparen.csstate = 4; ignore_backslash_newline++; break; + case '#': + ignore_backslash_newline++; + while ((c = getsc()) != '\0' && c != '\n') + ; + ignore_backslash_newline--; + break; } break;