eval: trim CR+LF in backtick('') and $()

modified:   eval.c
This commit is contained in:
KO Myung-Hun 2017-01-10 17:29:41 +09:00
parent f814ccfb8f
commit e0355b78a9

19
eval.c
View File

@ -880,10 +880,27 @@ expand(
c = '\n';
--newlines;
} else {
while ((c = shf_getc(x.u.shf)) == 0 || c == '\n')
while ((c = shf_getc(x.u.shf)) == 0 ||
#ifdef __OS2__
c == '\r' ||
#endif
c == '\n')
#ifdef __OS2__
{
if (c == '\r') {
c = shf_getc(x.u.shf);
if (c == -1)
c == '\r';
else if (c != '\n')
shf_ungetc(c, x.u.shf);
}
#endif
if (c == '\n')
/* save newlines */
newlines++;
#ifdef __OS2__
}
#endif
if (newlines && c != -1) {
shf_ungetc(c, x.u.shf);
c = '\n';