Is there precedent of --terse for omitting heading in other GNU utilities? Note that ps from procps supports --no-headers and --no-heading for the same purpose. This kind of thing is common, it'd be nice to try be consistent in its flag naming. In systemd systemctl supports --no-legend for this as well, *sigh*.
I do think the "Do one thing and do it well" argument is pretty weak in this case, considering there's already an --output flag for controlling the output. The argument suggests there should be no --output flag, and all output should always be produced in a fixed format to then be filtered by another program. To support controlling output rows by device, columns by field name, but not heading by boolean flag seems spuriously inconsistent to me. Regards, Vito Caputo On Sat, Mar 16, 2019 at 07:18:06PM +0000, Ed Neville wrote: > A --terse option: > > $ df -k --terse --output=used $PWD > > Should output a single integer if the path exists. > > --- > src/df.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/src/df.c b/src/df.c > index 041f2820d..c785ec6ec 100644 > --- a/src/df.c > +++ b/src/df.c > @@ -85,6 +85,9 @@ static bool file_systems_processed; > SunOS 4.1.3, for one. It is *not* necessary on GNU/Linux. */ > static bool require_sync; > > +/* If true we omit the header from output */ > +static bool terse_option; > + > /* Desired exit status. */ > static int exit_status; > > @@ -250,7 +253,8 @@ enum > NO_SYNC_OPTION = CHAR_MAX + 1, > SYNC_OPTION, > TOTAL_OPTION, > - OUTPUT_OPTION > + OUTPUT_OPTION, > + TERSE_OPTION > }; > > static struct option const long_options[] = > @@ -266,6 +270,7 @@ static struct option const long_options[] = > {"print-type", no_argument, NULL, 'T'}, > {"sync", no_argument, NULL, SYNC_OPTION}, > {"no-sync", no_argument, NULL, NO_SYNC_OPTION}, > + {"terse", no_argument, NULL, TERSE_OPTION}, > {"total", no_argument, NULL, TOTAL_OPTION}, > {"type", required_argument, NULL, 't'}, > {"exclude-type", required_argument, NULL, 'x'}, > @@ -554,6 +559,9 @@ get_header (void) > { > size_t col; > > + if( terse_option ) > + return; > + > alloc_table_row (); > > for (col = 0; col < ncolumns; col++) > @@ -1539,6 +1547,7 @@ or all file systems by default.\n\ > --sync invoke sync before getting usage info\n\ > "), stdout); > fputs (_("\ > + --terse do not print column headers\n\ > --total elide all entries insignificant to available > space,\n\ > and produce a grand total\n\ > "), stdout); > @@ -1581,6 +1590,7 @@ main (int argc, char **argv) > show_listed_fs = false; > human_output_opts = -1; > print_type = false; > + terse_option = false; > file_systems_processed = false; > exit_status = EXIT_SUCCESS; > print_grand_total = false; > @@ -1700,6 +1710,10 @@ main (int argc, char **argv) > print_grand_total = true; > break; > > + case TERSE_OPTION: > + terse_option = true; > + break; > + > case_GETOPT_HELP_CHAR; > case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); > > -- > 2.11.0 >