Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.sprintlink.net!in1.uu.net!news1.digital.com!nntp-hub2.barrnet.net!parc!fenner
From: fenner@parc.xerox.com (Bill Fenner)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Crontab and the % character
Date: 8 Sep 1995 22:47:33 GMT
Organization: Xerox Palo Alto Research Center
Lines: 45
Message-ID: <42qh65$s2@news.parc.xerox.com>
References: <marcus.225.0201FF80@ccelab.iastate.edu>
NNTP-Posting-Host: crevenia.parc.xerox.com
In article <marcus.225.0201FF80@ccelab.iastate.edu>,
Marcus I. Ryan <marcus@ccelab.iastate.edu> 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.