Date: Fri, 14 Mar 1997 09:34:33 +0000 From: Gareth McCaughan <gjm11@dpmms.cam.ac.uk> To: freebsd-bugs@freebsd.org Subject: Re: bin/2969: csh and/or builtin printf has problems with embedded commands Message-ID: <E0w5TNh-0006W2-00@g.pet.cam.ac.uk> In-Reply-To: Your message of "Thu, 13 Mar 1997 01:19:29 %2B0100." <199703130019.BAA04142@ghost.mep.ruhr-uni-bochum.de>
index | next in thread | previous in thread | raw e-mail
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.
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E0w5TNh-0006W2-00>
