From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost by hawkwind.utcs.toronto.edu with SMTP id <2728>; Wed, 18 Aug 1993 12:51:08 -0400 Return-Path: immd3.informatik.uni-erlangen.de!dalibor Received: from faui33.informatik.uni-erlangen.de ([131.188.33.2]) by hawkwind.utcs.toronto.edu with SMTP id <2727>; Wed, 18 Aug 1993 03:47:48 -0400 Received: from faui30a.informatik.uni-erlangen.de by immd3.informatik.uni-erlangen.de with SMTP (5.64+/7.2b-FAU) id AA13051; Wed, 18 Aug 93 09:47:27 +0200 From: Stefan Dalibor Message-Id: <9308180747.AA13051@faui33.informatik.uni-erlangen.de> Date: Wed, 18 Aug 1993 03:47:25 -0400 To: rc-owner Subject: Re: Question about input redirection in -c Reply-To: dalibor@immd3.informatik.uni-erlangen.de Resent-To: rc Resent-Date: Wed, 18 Aug 1993 12:50:58 -0400 Resent-From: Chris Siebenmann Resent-Message-Id: <93Aug18.125108edt.2728@hawkwind.utcs.toronto.edu> > I.e., you are conflating "stdin" with "the place rc reads commands > from". Yes, thanks - I was indeed under the impression that `<' would do input source redirection, not just file-descriptor manipulation. In the end, it turned out to be easy (like most things with rc): rc -c 'pwd; exec <0=]; . -i /dev/tty' does what I want (use readline() when sourcing the tty). Some memory nitpicking: Purify suggested the following changes to input.c; the first hunk avoids a memory leak when using rc with readline (the documentation for GNU-readline says that the strings returned by readline() should be freed if no longer needed), the second prevents accessing uninitialized memory (as istack's fd-component isn't initialized by pushstring()). The diffs are against plain rc-1.4. Purify detected a few other minor memory leaks, but I leave it to the author to plug them in the next release, as promised in an earlier message :). Stefan *** rc-1.4/input.c Fri Dec 11 10:21:17 1992 --- input.c Tue Aug 17 17:04:51 1993 *************** *** 129,132 **** --- 129,133 ---- strcpy(inbuf+2, rlinebuf); strcat(inbuf+2, "\n"); + efree(rlinebuf); } } else *************** *** 214,222 **** efree(inbuf); --istack; ! realgchar = (istack->t == iString ? stringgchar : fdgchar); ! if (istack->fd == -1) { /* top of input stack */ realgchar = dead; realugchar = ugdead; } last = istack->last; eofread = istack->eofread; --- 215,226 ---- efree(inbuf); --istack; ! if(istack->t == iString) ! realgchar = stringgchar; ! else if (istack->fd == -1) { /* top of input stack */ realgchar = dead; realugchar = ugdead; } + else + realgchar = fdgchar; last = istack->last; eofread = istack->eofread;