From owner-svn-src-stable@freebsd.org Wed Jul 19 20:22:17 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87D19D7D7C4; Wed, 19 Jul 2017 20:22:17 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5EE076A87C; Wed, 19 Jul 2017 20:22:17 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6JKMGHW019832; Wed, 19 Jul 2017 20:22:16 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6JKMGgo019830; Wed, 19 Jul 2017 20:22:16 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201707192022.v6JKMGgo019830@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Wed, 19 Jul 2017 20:22:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r321241 - stable/11/usr.sbin/cron/crontab X-SVN-Group: stable-11 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/11/usr.sbin/cron/crontab X-SVN-Commit-Revision: 321241 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jul 2017 20:22:17 -0000 Author: ngie Date: Wed Jul 19 20:22:16 2017 New Revision: 321241 URL: https://svnweb.freebsd.org/changeset/base/321241 Log: 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. Modified: stable/11/usr.sbin/cron/crontab/crontab.1 stable/11/usr.sbin/cron/crontab/crontab.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/cron/crontab/crontab.1 ============================================================================== --- stable/11/usr.sbin/cron/crontab/crontab.1 Wed Jul 19 19:53:07 2017 (r321240) +++ stable/11/usr.sbin/cron/crontab/crontab.1 Wed Jul 19 20:22:16 2017 (r321241) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 13, 2010 +.Dd December 20, 2016 .Dt CRONTAB 1 .Os .Sh NAME @@ -31,7 +31,8 @@ .Op Fl u Ar user { .Fl l | -.Fl r | +.Fl r Op Fl f +| .Fl e } .Sh DESCRIPTION @@ -97,6 +98,11 @@ option for safety's sake. Display the current crontab on standard output. .It Fl r Remove the current crontab. +By default the +.Fl r +option prompts for confirmation, adding the +.Fl f +option will attempt to remove the current crontab without confirmation. .It Fl e Edit the current crontab using the editor specified by the Modified: stable/11/usr.sbin/cron/crontab/crontab.c ============================================================================== --- stable/11/usr.sbin/cron/crontab/crontab.c Wed Jul 19 19:53:07 2017 (r321240) +++ stable/11/usr.sbin/cron/crontab/crontab.c Wed Jul 19 20:22:16 2017 (r321241) @@ -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)