summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron/crontab/crontab.c
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-07-19 20:26:35 +0000
committerngie <ngie@FreeBSD.org>2017-07-19 20:26:35 +0000
commit511f7c92ab611743edfe7e1307d7503726c72dda (patch)
tree19f8c235e8c0d8517fd2bf3c800dd252d26fefbc /usr.sbin/cron/crontab/crontab.c
parent36bb51434035ca6d3afcaf65ea3887b2262d1c1c (diff)
downloadFreeBSD-src-511f7c92ab611743edfe7e1307d7503726c72dda.zip
FreeBSD-src-511f7c92ab611743edfe7e1307d7503726c72dda.tar.gz
MFC r310329:
r310329 (by cem): Add a 'force' option for non-interactive crontab removal Add a '-f' option to force crontab '-r' to be non-interactive.
Diffstat (limited to 'usr.sbin/cron/crontab/crontab.c')
-rw-r--r--usr.sbin/cron/crontab/crontab.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c
index 933450b..53c5840 100644
--- a/usr.sbin/cron/crontab/crontab.c
+++ b/usr.sbin/cron/crontab/crontab.c
@@ -63,6 +63,7 @@ static char Filename[MAX_FNAME];
static FILE *NewCrontab;
static int CheckErrorCount;
static enum opt_t Option;
+static int fflag;
static struct passwd *pw;
static void list_cmd(void),
delete_cmd(void),
@@ -79,7 +80,7 @@ usage(char *msg)
fprintf(stderr, "crontab: usage error: %s\n", msg);
fprintf(stderr, "%s\n%s\n",
"usage: crontab [-u user] file",
- " crontab [-u user] { -e | -l | -r }");
+ " crontab [-u user] { -l | -r [-f] | -e }");
exit(ERROR_EXIT);
}
@@ -142,7 +143,7 @@ parse_args(argc, argv)
strcpy(RealUser, User);
Filename[0] = '\0';
Option = opt_unknown;
- while ((argch = getopt(argc, argv, "u:lerx:")) != -1) {
+ while ((argch = getopt(argc, argv, "u:lerx:f")) != -1) {
switch (argch) {
case 'x':
if (!set_debug_flags(optarg))
@@ -172,6 +173,9 @@ parse_args(argc, argv)
usage("only one operation permitted");
Option = opt_edit;
break;
+ case 'f':
+ fflag = 1;
+ break;
default:
usage("unrecognized option");
}
@@ -282,7 +286,7 @@ delete_cmd() {
char n[MAX_FNAME];
int ch, first;
- if (isatty(STDIN_FILENO)) {
+ if (!fflag && isatty(STDIN_FILENO)) {
(void)fprintf(stderr, "remove crontab for %s? ", User);
first = ch = getchar();
while (ch != '\n' && ch != EOF)
OpenPOWER on IntegriCloud