From owner-freebsd-bugs Sat Sep 9 06:16:21 1995 Return-Path: bugs-owner Received: (from majordom@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id GAA16750 for bugs-outgoing; Sat, 9 Sep 1995 06:16:21 -0700 Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id GAA16744 for ; Sat, 9 Sep 1995 06:16:20 -0700 Received: from crevenia.parc.xerox.com ([13.2.116.11]) by alpha.xerox.com with SMTP id <17237(2)>; Fri, 8 Sep 1995 15:48:12 PDT Received: by crevenia.parc.xerox.com id <177475>; Fri, 8 Sep 1995 15:47:37 -0700 Newsgroups: comp.unix.bsd.freebsd.misc From: Bill Fenner To: bugs@freebsd.org To: marcus@ccelab.iastate.edu Subject: Re: Crontab and the % character References: Organization: Xerox Palo Alto Research Center Message-Id: <95Sep8.154737pdt.177475@crevenia.parc.xerox.com> Date: Fri, 8 Sep 1995 15:47:34 PDT Sender: bugs-owner@freebsd.org Precedence: bulk In article , Marcus I. Ryan wrote: >I issue the command - stathtml `date +"%B %b"` >If I use the %'s by themselves then it interprets them as special control >characters, but if I put a \ in front of each, the command is interpreted >literally (i.e. "\%B \%b"). This is a bug. Try this patch. It turns "\%" into "%", "\\" into "\", and leaves "\*" (where * is any character other than % or \) alone. Bill --- usr.sbin/cron/cron/do_command.c.orig Fri Sep 8 15:23:27 1995 +++ usr.sbin/cron/cron/do_command.c Fri Sep 8 15:40:49 1995 @@ -122,13 +122,21 @@ * command, and subsequent characters are the additional input to * the command. Subsequent %'s will be transformed into newlines, * but that happens later. + * + * If there are escaped %'s, remove the escape character. */ /*local*/{ register int escaped = FALSE; register int ch; + register char *p; - for (input_data = e->cmd; ch = *input_data; input_data++) { + for (input_data = p = e->cmd; ch = *input_data; + input_data++, p++) { + if (p != input_data) + *p = ch; if (escaped) { + if (ch == '%' || ch == '\\') + *--p = ch; escaped = FALSE; continue; } @@ -141,6 +149,7 @@ break; } } + *p = '\0'; } /* fork again, this time so we can exec the user's command.