Re: find: print trailing slash for directories

Martin Schulte <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
Hi!

> Could somebody please advise, if there is some easy way to patch this
> myself?

DISCLAIMER:
- For the reasons mentioned here before I don't consider this a good idea but as long as you promise not to tell anyone that it was me you provided the patch ;-)
- I tried it with Debian 11
- It has not been thoroughly tested 

In file find/pred.d in the body of the function pred_print replace

  print_quoted (pred_ptr->args.printf_vec.stream,
                pred_ptr->args.printf_vec.quote_opts,
                pred_ptr->args.printf_vec.dest_is_tty,
                "%s\n", pathname);

by

  if ( stat_buf->st_mode & S_IFDIR ) {
    print_quoted (pred_ptr->args.printf_vec.stream,
                  pred_ptr->args.printf_vec.quote_opts,
                  pred_ptr->args.printf_vec.dest_is_tty,
                  "%s/\n", pathname);
  } else {
    print_quoted (pred_ptr->args.printf_vec.stream,
                  pred_ptr->args.printf_vec.quote_opts,
                  pred_ptr->args.printf_vec.dest_is_tty,
                  "%s\n", pathname);
  }

Best regards,

Martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.