Give a more expected behavior to -[hns] options, defaulting to all

parameters instead of ignoring the options and giving the old-style
default output.

Approved by:	re (kib), bz (mentor)
This commit is contained in:
Jamie Gritton 2009-07-08 15:57:22 +00:00
parent f9bc4dcb56
commit 4d4d887907
2 changed files with 18 additions and 11 deletions

View File

@ -25,7 +25,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd May 27, 2009 .Dd July 8, 2009
.Dt JLS 8 .Dt JLS 8
.Os .Os
.Sh NAME .Sh NAME
@ -54,6 +54,8 @@ for a description of some core parameters.
.Pp .Pp
If no If no
.Ar parameters .Ar parameters
or any of the options
.Fl hns
are given, the following four columns will be printed: are given, the following four columns will be printed:
jail identifier (jid), IP address (ip4.addr), hostname (host.hostname), jail identifier (jid), IP address (ip4.addr), hostname (host.hostname),
and path (path). and path (path).
@ -66,17 +68,20 @@ List
as well as active jails. as well as active jails.
.It Fl h .It Fl h
Print a header line containing the parameters listed. Print a header line containing the parameters listed.
If no parameters are given on the command line, the default output always If no parameters are given on the command line,
contains a header. .Va all
is assumed.
.It Fl n .It Fl n
Print parameters in Print parameters in
.Dq name=value .Dq name=value
format, where each parameter is preceded by its name. format, where each parameter is preceded by its name.
This option is ignored for the default four-column output. If no parameters are given on the command line,
.Va all
is assumed.
.It Fl q .It Fl q
Put quotes around parameters if they contain spaces or quotes, or are Put quotes around parameters if they contain spaces or quotes, or are
the empty string. the empty string.
.It Fl c .It Fl s
Print parameters suitable for passing to Print parameters suitable for passing to
.Xr jail 8 , .Xr jail 8 ,
skipping read-only and unused parameters. skipping read-only and unused parameters.

View File

@ -88,7 +88,8 @@ main(int argc, char **argv)
jname = optarg; jname = optarg;
break; break;
case 'h': case 'h':
pflags = (pflags & ~PRINT_SKIP) | PRINT_HEADER; pflags = (pflags & ~(PRINT_SKIP | PRINT_VERBOSE)) |
PRINT_HEADER;
break; break;
case 'n': case 'n':
pflags = (pflags & ~PRINT_VERBOSE) | PRINT_NAMEVAL; pflags = (pflags & ~PRINT_VERBOSE) | PRINT_NAMEVAL;
@ -101,7 +102,8 @@ main(int argc, char **argv)
PRINT_NAMEVAL | PRINT_QUOTED | PRINT_SKIP; PRINT_NAMEVAL | PRINT_QUOTED | PRINT_SKIP;
break; break;
case 'v': case 'v':
pflags = (pflags & ~(PRINT_NAMEVAL | PRINT_SKIP)) | pflags = (pflags &
~(PRINT_HEADER | PRINT_NAMEVAL | PRINT_SKIP)) |
PRINT_VERBOSE; PRINT_VERBOSE;
break; break;
default: default:
@ -110,7 +112,9 @@ main(int argc, char **argv)
/* Add the parameters to print. */ /* Add the parameters to print. */
if (optind == argc) { if (optind == argc) {
if (pflags & PRINT_VERBOSE) { if (pflags & (PRINT_HEADER | PRINT_NAMEVAL))
add_param("all", NULL, (size_t)0, NULL, JP_USER);
else if (pflags & PRINT_VERBOSE) {
add_param("jid", NULL, (size_t)0, NULL, JP_USER); add_param("jid", NULL, (size_t)0, NULL, JP_USER);
add_param("host.hostname", NULL, (size_t)0, NULL, add_param("host.hostname", NULL, (size_t)0, NULL,
JP_USER); JP_USER);
@ -122,9 +126,7 @@ main(int argc, char **argv)
add_param("ip6.addr", NULL, (size_t)0, NULL, add_param("ip6.addr", NULL, (size_t)0, NULL,
JP_USER | JP_OPT); JP_USER | JP_OPT);
} else { } else {
pflags = (pflags & pflags |= PRINT_DEFAULT;
~(PRINT_NAMEVAL | PRINT_SKIP | PRINT_VERBOSE)) |
PRINT_DEFAULT;
add_param("jid", NULL, (size_t)0, NULL, JP_USER); add_param("jid", NULL, (size_t)0, NULL, JP_USER);
add_param("ip4.addr", NULL, (size_t)0, NULL, JP_USER); add_param("ip4.addr", NULL, (size_t)0, NULL, JP_USER);
add_param("host.hostname", NULL, (size_t)0, NULL, add_param("host.hostname", NULL, (size_t)0, NULL,