From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1024143-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 926241382C5 for <garchives@archives.gentoo.org>; Tue, 15 May 2018 00:11:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B4329E08FC; Tue, 15 May 2018 00:11:52 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 92266E08FC for <gentoo-commits@lists.gentoo.org>; Tue, 15 May 2018 00:11:52 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E273F335C8C for <gentoo-commits@lists.gentoo.org>; Tue, 15 May 2018 00:11:50 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 80CD5260 for <gentoo-commits@lists.gentoo.org>; Tue, 15 May 2018 00:11:48 +0000 (UTC) From: "William Hubbs" <williamh@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" <williamh@gentoo.org> Message-ID: <1526342404.a7f475ca04856ef8232364c5b0c3191566b0696c.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: man/, src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: man/rc-service.8 src/rc/rc-service.c X-VCS-Directories: man/ src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: a7f475ca04856ef8232364c5b0c3191566b0696c X-VCS-Branch: master Date: Tue, 15 May 2018 00:11:48 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 20cf924a-a4f7-4cc7-a915-87ce1296ca46 X-Archives-Hash: 6961246fd1cddab77c3a90002ccfc13f commit: a7f475ca04856ef8232364c5b0c3191566b0696c Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> AuthorDate: Tue May 15 00:00:04 2018 +0000 Commit: William Hubbs <williamh <AT> gentoo <DOT> org> CommitDate: Tue May 15 00:00:04 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a7f475ca rc-service: add a --dry-run option This is for #225. man/rc-service.8 | 6 ++++++ src/rc/rc-service.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/man/rc-service.8 b/man/rc-service.8 index 8f075de4..a0202a8e 100644 --- a/man/rc-service.8 +++ b/man/rc-service.8 @@ -35,6 +35,9 @@ .Fl e , -exists .Ar service .Nm +.Fl Z , -dry-run +.Ar service +.Nm .Fl l , -list .Nm .Fl r , -resolve @@ -68,6 +71,9 @@ return 0 if it can find otherwise -1. .Fl r , -resolve does the same and also prints the full path of the service to stdout. +.Pp +.Fl Z , -dry-run +prints out the commands it would execute rather than executing them. .Sh SEE ALSO .Xr openrc 8 , .Xr stdout 3 diff --git a/src/rc/rc-service.c b/src/rc/rc-service.c index 8e7b00dc..77f0336b 100644 --- a/src/rc/rc-service.c +++ b/src/rc/rc-service.c @@ -29,7 +29,7 @@ const char *applet = NULL; const char *extraopts = NULL; -const char *getoptstring = "ce:ilr:IN" getoptstring_COMMON; +const char *getoptstring = "ce:ilr:INZ" getoptstring_COMMON; const struct option longopts[] = { { "exists", 1, NULL, 'e' }, { "ifcrashed", 0, NULL, 'c' }, @@ -38,6 +38,7 @@ const struct option longopts[] = { { "ifnotstarted", 0, NULL, 'N' }, { "list", 0, NULL, 'l' }, { "resolve", 1, NULL, 'r' }, + { "dry-run", 0, NULL, 'Z' }, longopts_COMMON }; const char * const longopts_help[] = { @@ -48,6 +49,7 @@ const char * const longopts_help[] = { "if the service is not started then run the command", "list all available services", "resolve the service name to an init script", + "dry run (show what would happen)", longopts_help_COMMON }; const char *usagestring = "" \ @@ -112,6 +114,9 @@ int main(int argc, char **argv) free(service); return EXIT_SUCCESS; /* NOTREACHED */ + case 'Z': + setenv("IN_DRYRUN", "yes", 1); + break; case_RC_COMMON_GETOPT }