Try this patch. It should ignore that cat is a built-in of /bin/cat and
runs /bin/cat instead when it is the last command of ``. Let me know if
this fixes the problem.
--- old/sh/xec.c Mon Aug 18 17:53:43 2014
+++ new/sh/xec.c Mon Aug 18 18:23:58 2014
@@ -1253,9 +1253,14 @@
}
if(np && pipejob==2)
{
- job_unlock();
- nlock--;
- pipejob = 1;
+ if(shp->comsub==1 && np &&
is_abuiltin(np) && *np->nvname=='/')
+ np = 0;
+ else
+ {
+ job_unlock();
+ nlock--;
+ pipejob = 1;
+ }
}
/* check for builtins */
if(np && is_abuiltin(np))
On Mon, Aug 18, 2014 at 8:50 PM, David Korn <[email protected]> wrote:
> I should be able to detect that cat is a builtin version of /bin/cat and
> implicitly treat it as /bin/cat. I'll put this on my list.
>
>
>
> On Mon, Aug 18, 2014 at 9:18 AM, Dr. Werner Fink <[email protected]> wrote:
>
>> On Wed, Aug 06, 2014 at 09:03:22PM -0400, David Korn wrote:
>> > I have attached a different fix that doesn't have the problem the last
>> one
>> > does. However, if the last command in the pipeline is a shell
>> built-in, it
>> > could hang for large output.
>> >
>> > Let me know if this works for you.
>>
>> It hangs as `cat' is a shell built-in in normal case:
>>
>> /usr/src/packages/BUILD/ksh93> ./arch/linux.i386-64/src/cmd/ksh93/ksh
>> /usr/src/packages/BUILD/ksh93> x=`cat ~/testfile.txt | cat -`
>> Killed
>>
>> whereas this one
>>
>> /usr/src/packages/BUILD/ksh93> x=`cat ~/testfile.txt | /bin/cat -`
>> /usr/src/packages/BUILD/ksh93>
>>
>> does work ... IMHO both should work. The test suite does survive with
>> this patch.
>>
>> Werner
>>
>> >
>> >
>> >
>> > On Fri, Jul 25, 2014 at 4:04 AM, Dr. Werner Fink <[email protected]>
>> wrote:
>> >
>> > > On Thu, Jul 24, 2014 at 11:35:01AM -0400, David Korn wrote:
>> > > > 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.
>> > > >
>>
>> --
>> "Having a smoking section in a restaurant is like having
>> a peeing section in a swimming pool." -- Edward Burr
>>
>
>
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers