coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] basename/dirname can't handle stdin?


From: Jim Meyering
Subject: Re: [coreutils] basename/dirname can't handle stdin?
Date: Thu, 13 Jan 2011 08:53:01 +0100

Jeff Blaine wrote:
> Eric, now that I've got the prereqs in place,
> built coreutils from git successfully, and read the
> coreutils HACKING file, let's make sure I am on your
> page:
>
> In no order:
>
> * Snarf getopt_long arg processing from wc.c or other
>   you mentioned

getopt_long?  There will be some of that (for the new options),
but most of the new code will be to process stdin, and you can
use code nearly identical to what wc uses:

  int i;
  ok = true;
  for (i = 0; /* */; i++)
    {
      bool skip_file = false;
      enum argv_iter_err ai_err;
      char *file_name = argv_iter (ai, &ai_err);
      ...

The preceding set-up code can be mostly-reused, too,

  bool read_tokens = false;
  struct argv_iterator *ai;
  if (files_from)
    {

with the exception that the "else"-block that sets up
to get names from argv.  I.e., while wc, du, sort can take
many arguments from argv, basename cannot.

> * Add --filter (combined with the lack of file args) to handle
>   processing of stdin
> * Add --files-from0 per wc.c code (found it there)

it's --files0-from

> * Add --suffix [suffix] to enable suffix killing (using
>   SUFFIX as the 2nd arg will no longer work going forward)
> * Update usage() obviously
>
> Correct?  Anything else?

  * Update NEWS to mention the new functionality.
  * Update doc/coreutils.texi
  * add tests to exercise the new behavior (as I mentioned earlier)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]