I finally got a chance to look at this. The problem is that the standard is ambiguous about when a command substitution ends.
The bourne shell used a pipe for command substitution and command substitution terminated when the pipe closed. Thus, if you had a command the wrote on standard output, forked and exited and the child wrote on that pipe, the output from both processes was part of the command substitution. ksh considered the command substitution done when the command completed and used memory for files less that 64K(IOBSIZE) and this created a tmp file if it was larger. I tried to restore the old bourne shell semantics for `` so that the foreback test would work. However, this caused the example you have to hang. Here is a change which should fix this by using pipes for all `` not just large ones. Here is the one line patch: --- old/sh/subshell.c Wed Apr 2 09:57:00 2014 +++new/sh/subshell.c Thu Jul 24 11:19:43 2014 @@ -593,7 +574,7 @@ sp->tmpfd = -1; sp->pipefd = -1; /* use sftmp() file for standard output */ - if(!(iop = sftmp(comsub==1?PIPE_BUF:IOBSIZE))) + if(!(iop = sftmp(comsub==1?0:IOBSIZE))) { sfswap(sp->saveout,sfstdout); errormsg(SH_DICT,ERROR_system(1),e_tmpcreate); Let me know. On Fri, Jul 18, 2014 at 10:34 AM, Dr. Werner Fink <wer...@suse.de> wrote: > On Fri, Jul 18, 2014 at 04:05:32PM +0200, Werner Fink wrote: > > On Wed, Jul 16, 2014 at 11:01:58AM +0200, Werner Fink wrote: > > > Hi, > > > > > > with the following lines the ksh93u upto ksh93v- 2014-06-25 do hang: > > > > > > dd if=/dev/zero of=testfile.txt bs=1 count=65537 > > > x=`cat testfile.txt | cat -` > > > > > > ... it works with count=65536 and/or > > > > > > x=$(cat testfile.txt | cat -) > > > > > > but AFAIK the backticks are very common and also supported. > > > > > > Btw: Even a Ctrl-C does *not* interrupt the running ksh: > > > > > > noether:~ # strace -p 31289 > > > Process 31289 attached - interrupt to quit > > > write(1, "\0", 1) = ? ERESTARTSYS (To be > restarted) > > > --- {si_signo=SIGINT, si_code=SI_KERNEL, si_value={int=1060230178, > ptr=0x7f943f31d422}} (Interrupt) --- > > > rt_sigreturn(0x7d6ef8) = -1 EINTR (Interrupted > system call) > > > write(1, "\0", 1) = ? ERESTARTSYS (To be > restarted) > > > > After debugging I found that the following change > > > > ---------------------------* snip > *--------------------------------------- > > --- ksh93/src/cmd/ksh93/sh/macro.c > > +++ ksh93/src/cmd/ksh93/sh/macro.c 2014-07-18 13:50:47.590235743 +0000 > > @@ -2198,7 +2198,7 @@ static void comsubst(Mac_t *mp,register > > mp->shp->inlineno = error_info.line+mp->shp->st.firstline; > > t = (Shnode_t*)sh_parse(mp->shp, sp,SH_EOF|SH_NL); > > mp->shp->inlineno = c; > > - type = 1; > > + type = 3; > > } > > #if KSHELL > > if(t) > > ---------------------------* snap > *--------------------------------------- > > but this causes trouble: > > test basic begins at 2014-07-18+14:20:30 > basic.sh[447]: ``command substitution background process output > error -- got 'fore', expected 'foreback' > test basic failed at 2014-07-18+14:21:11 with exit code 1 [ 110 tests 1 > error ] > test basic(C.UTF-8) begins at 2014-07-18+14:21:11 > basic.sh[447]: ``command substitution background process output > error -- got 'fore', expected 'foreback' > test basic(C.UTF-8) failed at 2014-07-18+14:21:52 with exit code 1 [ 110 > tests 1 error ] > test basic(shcomp) begins at 2014-07-18+14:21:52 > shcomp-basic.ksh[447]: ``command substitution background process > output error -- got 'fore', expected 'foreback' > > -- > "Having a smoking section in a restaurant is like having > a peeing section in a swimming pool." -- Edward Burr >
_______________________________________________ ast-developers mailing list ast-developers@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-developers