occurs during counting, then an error message is printed to the stderr and
.B fincore
continues processing the rest of files listed in a command line.
+
+The default output is subject to change. So whenever possible, you should
+avoid using default outputs in your scripts. Always explicitly define expected
+columns by using
+.B \-\-output
+.I columns-list
+in environments where a stable output is required.
.SH OPTIONS
.TP
.BR \-n , " \-\-noheadings"
.BR \-b , " \-\-bytes"
Print the SIZE column in bytes rather than in a human-readable format.
.TP
+.BR \-o , " \-\-output \fIlist\fP"
+Define output columns. See the \fB\-\-help\fP output to get a list of the
+currently supported columns. The default list of columns may be extended if \fIlist\fP is
+specified in the format \fI+list\fP.
+.TP
\fB\-V\fR, \fB\-\-version\fR
Display version information and exit.
.TP
static void __attribute__((__noreturn__)) usage(FILE *out)
{
+ size_t i;
+
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] file...\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
- fputs(_(" -b, --bytes print sizes in bytes rather than in human readable format\n"), out);
- fputs(_(" -n, --noheadings don't print headings\n"), out);
+ fputs(_(" -b, --bytes print sizes in bytes rather than in human readable format\n"), out);
+ fputs(_(" -n, --noheadings don't print headings\n"), out);
+ fputs(_(" -o, --output <list> output columns\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
+ fprintf(out, _("\nAvailable columns (for --output):\n"));
+
+ for (i = 0; i < ARRAY_SIZE(infos); i++)
+ fprintf(out, " %11s %s\n", infos[i].name, _(infos[i].help));
+
fprintf(out, USAGE_MAN_TAIL("fincore(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
int c;
size_t i;
int rc = EXIT_SUCCESS;
+ char *outarg = NULL;
struct fincore_control ctl = {
- .pagesize = getpagesize()
+ .pagesize = getpagesize()
};
static const struct option longopts[] = {
{ "bytes", no_argument, NULL, 'b' },
{ "noheadings", no_argument, NULL, 'n' },
+ { "output", required_argument, NULL, 'o' },
{ "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 },
textdomain(PACKAGE);
atexit(close_stdout);
- while ((c = getopt_long (argc, argv, "bnVh", longopts, NULL)) != -1) {
+ while ((c = getopt_long (argc, argv, "bno:Vh", longopts, NULL)) != -1) {
switch (c) {
case 'b':
ctl.bytes = 1;
case 'n':
ctl.noheadings = 1;
break;
+ case 'o':
+ outarg = optarg;
+ break;
case 'V':
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
columns[ncolumns++] = COL_FILE;
}
+ if (outarg && string_add_to_idarray(outarg, columns, ARRAY_SIZE(columns),
+ &ncolumns, column_name_to_id) < 0)
+ return EXIT_FAILURE;
+
scols_init_debug(0);
ctl.tb = scols_new_table();
if (!ctl.tb)