HIDE_OPTION,
HYPERLINK_OPTION,
INDICATOR_STYLE_OPTION,
- NULL_OPTION,
QUOTING_STYLE_OPTION,
SHOW_CONTROL_CHARS_OPTION,
SI_OPTION,
SORT_OPTION,
TIME_OPTION,
- TIME_STYLE_OPTION
+ TIME_STYLE_OPTION,
+ ZERO_OPTION,
};
static struct option const long_options[] =
{"human-readable", no_argument, NULL, 'h'},
{"inode", no_argument, NULL, 'i'},
{"kibibytes", no_argument, NULL, 'k'},
- {"null", no_argument, NULL, NULL_OPTION},
{"numeric-uid-gid", no_argument, NULL, 'n'},
{"no-group", no_argument, NULL, 'G'},
{"hide-control-chars", no_argument, NULL, 'q'},
{"tabsize", required_argument, NULL, 'T'},
{"time", required_argument, NULL, TIME_OPTION},
{"time-style", required_argument, NULL, TIME_STYLE_OPTION},
+ {"zero", no_argument, NULL, ZERO_OPTION},
{"color", optional_argument, NULL, COLOR_OPTION},
{"hyperlink", optional_argument, NULL, HYPERLINK_OPTION},
{"block-size", required_argument, NULL, BLOCK_SIZE_OPTION},
intmax_t p = pos[i];
printf (" %"PRIdMAX, p);
}
- putchar (eolbyte);
+ putchar ('\n');
}
}
{
print_current_files ();
if (pending_dirs)
- dired_outbyte (eolbyte);
+ dired_outbyte ('\n');
}
else if (n_files <= 1 && pending_dirs && pending_dirs->next == 0)
print_dir_name = false;
/* No need to free these since we're about to exit. */
dired_dump_obstack ("//DIRED//", &dired_obstack);
dired_dump_obstack ("//SUBDIRED//", &subdired_obstack);
- printf ("//DIRED-OPTIONS// --quoting-style=%s%c",
- quoting_style_args[get_quoting_style (filename_quoting_options)],
- eolbyte);
+ printf ("//DIRED-OPTIONS// --quoting-style=%s\n",
+ quoting_style_args[get_quoting_style (filename_quoting_options)]);
}
if (LOOP_DETECT)
indicator_style_types);
break;
- case NULL_OPTION:
- eolbyte = 0;
- break;
-
case QUOTING_STYLE_OPTION:
quoting_style_opt = XARGMATCH ("--quoting-style", optarg,
quoting_style_args,
print_scontext = true;
break;
+ case ZERO_OPTION:
+ eolbyte = 0;
+ hide_control_chars_opt = false;
+ if (format_opt != long_format)
+ format_opt = one_per_line;
+ print_with_color = false;
+ quoting_style_opt = literal_quoting_style;
+ break;
+
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
}
}
-
- static signed char const default_format[] =
- {
- [LS_LS] = -1,
- [LS_MULTI_COL] = many_per_line,
- [LS_LONG_FORMAT] = long_format,
- };
- int form = format_opt < 0 ? default_format[ls_mode] : format_opt;
- format = form < 0 ? (stdout_isatty () ? many_per_line : one_per_line) : form;
+ format = (0 <= format_opt ? format_opt
+ : ls_mode == LS_LS ? (stdout_isatty ()
+ ? many_per_line : one_per_line)
+ : ls_mode == LS_MULTI_COL ? many_per_line
+ : /* ls_mode == LS_LONG_FORMAT */ long_format);
/* If the line length was not set by a switch but is needed to determine
output, go to the work of obtaining it from the environment. */
dirname_quoting_options = clone_quoting_options (NULL);
set_char_quoting (dirname_quoting_options, ':', 1);
- /* --dired is meaningful only with --format=long (-l).
+ /* --dired is meaningful only with --format=long (-l) and sans --hyperlink.
Otherwise, ignore it. FIXME: warn about this?
Alternatively, make --dired imply --format=long? */
- if (dired && (format != long_format || print_hyperlink))
- dired = false;
+ dired &= (format == long_format) & !print_hyperlink;
+
+ if (eolbyte < dired)
+ die (LS_FAILURE, 0, _("--dired and --zero are incompatible"));
/* If -c or -u is specified and not -l (or any other option that implies -l),
and no sort-type was specified, then sort by the ctime (-c) or atime (-u).
if (recursive || print_dir_name)
{
if (!first)
- dired_outbyte (eolbyte);
+ dired_outbyte ('\n');
first = false;
dired_indent ();
free (absolute_name);
- dired_outbyte (':');
- dired_outbyte (eolbyte);
+ dired_outstring (":\n");
}
/* Read the directory entries, and insert the subfiles into the 'cwd_file'
\n\
"), stdout);
fputs (_("\
- --null end each output line with NUL, not newline\n\
-n, --numeric-uid-gid like -l, but list numeric user and group IDs\n\
-N, --literal print entry names without quoting\n\
-o like -l, but do not list group information\n\
-x list entries by lines instead of by columns\n\
-X sort alphabetically by entry extension\n\
-Z, --context print any security context of each file\n\
+ --zero end each output line with NUL, not newline\n\
-1 list one file per line. Avoid '\\n' with -q or -b\
\n\
"), stdout);