Date: Fri, 8 Sep 1995 15:47:34 PDT From: Bill Fenner <fenner@parc.xerox.com> To: marcus@ccelab.iastate.edu Subject: Re: Crontab and the % character Message-ID: <95Sep8.154737pdt.177475@crevenia.parc.xerox.com> References: <marcus.225.0201FF80@ccelab.iastate.edu>
index | next in thread | previous in thread | raw e-mail
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.
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?95Sep8.154737pdt.177475>
