On Fri, Mar 19, 2021 at 08:24:12AM -0600, Todd C. Miller wrote: > On Fri, 19 Mar 2021 13:22:35 +0100, Klemens Nanni wrote: > > > I argue it should be `-n' like all the daemons, e.g. vmd(8) and other > > parsers such as pfctl(8) do. > > Yes, please. I was about to make the same point.
Fair enough. I started with -d because that's what bpftrace has, but changing to -n for consistency makes sense to me. Index: btrace.8 =================================================================== RCS file: /cvs/src/usr.sbin/btrace/btrace.8,v retrieving revision 1.2 diff -u -p -u -p -r1.2 btrace.8 --- btrace.8 11 Sep 2020 08:16:15 -0000 1.2 +++ btrace.8 20 Mar 2021 04:38:55 -0000 @@ -46,6 +46,9 @@ Execute .Ar program . .It Fl l List all available probes. +.It Fl n +No action. +Parse the program and then exit. .It Fl p Ar pid Enable tracing on the indicated process ID (only one .Fl p Index: btrace.c =================================================================== RCS file: /cvs/src/usr.sbin/btrace/btrace.c,v retrieving revision 1.29 diff -u -p -u -p -r1.29 btrace.c --- btrace.c 8 Feb 2021 09:46:45 -0000 1.29 +++ btrace.c 20 Mar 2021 04:38:56 -0000 @@ -124,7 +124,7 @@ main(int argc, char *argv[]) int fd = -1, ch, error = 0; const char *filename = NULL, *btscript = NULL; const char *errstr; - int showprobes = 0, tracepid = -1; + int showprobes = 0, tracepid = -1, noaction = 0; setlocale(LC_ALL, ""); @@ -133,7 +133,7 @@ main(int argc, char *argv[]) err(1, "pledge"); #endif - while ((ch = getopt(argc, argv, "e:lp:v")) != -1) { + while ((ch = getopt(argc, argv, "e:lnp:v")) != -1) { switch (ch) { case 'e': btscript = optarg; @@ -141,6 +141,9 @@ main(int argc, char *argv[]) case 'l': showprobes = 1; break; + case 'n': + noaction = 1; + break; case 'p': if (tracepid != -1) usage(); @@ -178,6 +181,9 @@ main(int argc, char *argv[]) return error; } + if (noaction) + return error; + if (showprobes || g_nprobes > 0) { fd = open(__PATH_DEVDT, O_RDONLY); if (fd == -1) @@ -201,7 +207,7 @@ main(int argc, char *argv[]) __dead void usage(void) { - fprintf(stderr, "usage: %s [-lv] [-p pid] [-e program|file]\n", + fprintf(stderr, "usage: %s [-lnv] [-p pid] [-e program | file]\n", getprogname()); exit(1); }