Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Mar 1997 14:30:02 -0800 (PST)
From:      Gareth McCaughan <gjm11@dpmms.cam.ac.uk>
To:        freebsd-bugs
Subject:   Re: bin/2969: csh and/or builtin printf has problems with embedded commands 
Message-ID:  <199703142230.OAA15742@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/2969; it has been noted by GNATS.

From: Gareth McCaughan <gjm11@dpmms.cam.ac.uk>
To: freebsd-bugs@freebsd.org
Cc:  Subject: Re: bin/2969: csh and/or builtin printf has problems with embedded commands 
Date: Fri, 14 Mar 1997 09:34:33 +0000

 Robert Eckard wrote:
 
 > 	printf with a shell command as its argument
 > 	prints wrong results. Happens only for builtin printf
 > 	in /usr/bin/csh.
 
 What's actually happening is that the csh built-in printf isn't
 expanding its arguments. The "printf" builtin isn't actually
 documented in the manpage (!), but this sounds like a bug since
 it presumably is meant to behave like /usr/bin/printf.
 
 I believe that the following patch fixes the problem.
 
 ---------- patch begins ----------
 *** func.c.orig	Thu Mar 13 19:04:20 1997
 --- func.c	Fri Mar 14 09:27:40 1997
 ***************
 *** 1489,1497 ****
 --- 1489,1510 ----
       Char **v;
       struct command *t;
   {
 +     Char **newv;
       char **c;
       extern int progprintf __P((int, char **));
       int ret;
 + 
 +     gflag = 0;
 +     tglob(v);
 +     if (gflag) {
 + 	newv = globall(v);
 + 	if (newv == 0) {
 + 	    stderror(ERR_NAME | ERR_NOMATCH);
 + 	    return;
 + 	}
 + 	v = newv;
 + 	gargv=0;
 +     }
   
       ret = progprintf(blklen(v), c = short2blk(v));
       (void) fflush(cshout);
 ----------- patch ends -----------
 
 Incidentally, there is a memory leak somewhere around here in csh.
 (The arguments to "doprintf" aren't getting freed.) I'm not suggesting
 a fix because I really don't want to have to read the code carefully
 enough to be sure I wouldn't introduce a bug that freed things twice.
 
 >From a cursory look at the code I suspect that there are in fact
 about 100000 memory leaks of this kind. Yeeuch.
 
 -- 
 Gareth McCaughan       Dept. of Pure Mathematics & Mathematical Statistics,
 gjm11@dpmms.cam.ac.uk  Cambridge University, England.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703142230.OAA15742>