bug-findutils
[Top][All Lists]
Advanced

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

[bug #64816] support ls' --quoting-style= option


From: Christoph Anton Mitterer
Subject: [bug #64816] support ls' --quoting-style= option
Date: Wed, 25 Oct 2023 22:56:29 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?64816>

                 Summary: support ls' --quoting-style= option
                   Group: findutils
               Submitter: calestyo
               Submitted: Thu 26 Oct 2023 02:56:27 AM UTC
                Category: documentation
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 4.9.0
         Discussion Lock: Any
           Fixed Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Thu 26 Oct 2023 02:56:27 AM UTC By: Christoph Anton Mitterer <calestyo>
Hey.

The manpage says:
       -printf, -fprintf
              If the output is not going to a terminal, it is printed as-is. 
Otherwise, …
              The directives %f,  %h,  %l,
              %p  and %P are quoted.  This quoting is performed in the same
way as for GNU ls.


Let's see, I have a directory with lots of unusual filenames, which ls -1
prints like this:
# ls -1
'a'$'\n''b'
'c'$'\t''d'
'e'$'\r''f'
'g h'
'i'$'\n''j'
'k'$'\n\n'
strange-files
--foo
'\n'
????????????


# find . -mindepth 1 -maxdepth 1 
./--foo
./a?b
./????????????
./\n
./g h
./c?d
./e?f
./i?j
./strange-files
./k??

This seems to be ls' old default quoting style of "literal" which was changed
2015 with
https://github.com/coreutils/coreutils/commit/109b9220cead6e979d22d16327c4d9f8350431cc
.
Nowadays it uses actually usable output ;-) (quoting style "shell-escape").

I think it would be most useful if find would provide a counterpart that
allows setting the various quoting styles of ls.

Especially this should also work when output goes to a terminal.

So one could do e.g.
find … --quoting-style=shell-escape | \
while IFS='' read -r QUOTED_PATH; do
   eval 'PATH="${QUOTED_PATH}"'

   do_more_with "$PATH"
done

which should support even trailing newlines and the likes.


Of course, such escaping style would need to escape any characters considered
special in POSIX shells,... which I guess ls' quoting does.

I'd further guess/hope that this also includes any extensions by bash.


Cheers,
Chris.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64816>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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