Subject: Re: bug#49716: no -print0 for ls?

From: Bernhard Voelker <[email-masked]>
Date: Mon, 26 Jul 2021 21:52:26 +0200

On 7/26/21 5:00 PM, Pádraig Brady wrote:
> The patch set looks good thanks.

Wait - I see another reason why we didn't add it earlier:

The --null option is not compatible with about half of the other options of ls(1);
at least the actual output is more than questionable, and not usable in programmatic
context.  The -R option is the first one which obviously can't work as such.

The following options don't work well with --null, because they output other,
additional information or transform/escape the file names:

  -b, --escape               print C-style escapes for nongraphic characters
  -C                         list entries by columns
      --color[=WHEN]         colorize the output; WHEN can be 'always' (default
                               if omitted), 'auto', or 'never'; more info below
  -F, --classify             append indicator (one of */=>@|) to entries
      --file-type            likewise, except do not append '*'
      --full-time            like -l --time-style=full-iso
  -g                         like -l, but do not list owner
      --indicator-style=WORD  append indicator with style WORD to entry names:
                               none (default), slash (-p),
                               file-type (--file-type), classify (-F)
  -i, --inode                print the index number of each file
  -l                         use a long listing format
  -m                         fill width with a comma separated list of entries
  -n, --numeric-uid-gid      like -l, but list numeric user and group IDs
  -o                         like -l, but do not list group information
  -p, --indicator-style=slash
                             append / indicator to directories
  -q, --hide-control-chars   print ? instead of nongraphic characters
  -Q, --quote-name           enclose entry names in double quotes
      --quoting-style=WORD   use quoting style WORD for entry names:
                               literal, locale, shell, shell-always,
                               shell-escape, shell-escape-always, c, escape
                               (overrides QUOTING_STYLE environment variable)
  -R, --recursive            list subdirectories recursively
  -s, --size                 print the allocated size of each file, in blocks
  -x                         list entries by lines instead of by columns
  -Z, --context              print any security context of each file

While the actual change is small - i.e., change the newline to a '\0' for the eolchar,
I'm afraid that it will become quite hairy to discuss the actual problems of future users
of that option when combining it with one of the above options.

I really have some qualms with adding --null to ls(1).  If this is about listing files
in the current directory in a certain sort order for a processing purpose, then this
would IMO warrant a new utility rather than blowing ls(1).

Have a nice day,
Berny