bugfindutils - Bugs: bug #62561, "files0-from" expression...

 
 

bug #62561: "files0-from" expression prints "find: '\n' No such file or directory "

Submitter:  Shuiqing Zhou <zhoushuiqing>
Submitted:  Thu 02 Jun 2022 10:21:25 AM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Working as Intended
Privacy:  Public Assigned to:  berny
Originator Name:  Open/Closed:  Closed
Release:  4.9.0 Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 02 Jun 2022 05:13:27 PM UTC, comment #1: 

Thanks for the report and the patch.

I'm afraid it's not a bug or something to fix or handle in find,
but rather a misunderstanding on your side how -files0-from
works.

The only valid entry separator in the input from -files0-from
is the NUL character.  This is intentional to allow arbitrary
input.

E.g. it is allowed and fully okay to have a file named '\n':

$ echo hello > '\n'

$ cat '\n'
hello

$ rm -v '\n'
removed '\n'


P.S. editors like vim usually handle text files, and POSIX
says that text files must end on a newline.
Therefore, it's not good to edit the binary input for -files0-from
with a text editor, because they change the end of the file:


$ printf '/home\0' > startpoint.txt

$ od -tx1z startpoint.txt
0000000 2f 68 6f 6d 65 00                                >/home.<
0000006

# Edit the file with a text editor and save it.
$ vi startpoint.txt

$ od -tx1z startpoint.txt
0000000 2f 68 6f 6d 65 00 0a                             >/home..<
0000007

See the trailing newline.

Therefore, I'm closing this as 'works as intended'.

Bernhard Voelker <berny>
Group administrator
Thu 02 Jun 2022 10:21:25 AM UTC, original submission:  

I write some directories into startpoint.txt, and manually add '^@' behind dirs. This symbol means '\0'.

Then, run find in command line:
[root@fedora /]# ls /home
file1  file2 startpoint.txt
[root@fedora /]# vim /home/startpoint.txt
/home^@
[root@fedora /]# find -files0-from startpoint.txt -name "file*"
/home/file1
/home/file2
find: ‘\n’: No such file or directory

[root@fedora /]# find --version
find (GNU findutils) 4.9.0

Linux: Fedora36

I think '\n' should not be processed, of course, '\n' can be removed. But find can skip the '\n', I think.
so I added some code to handle this.

Others, I hope to see some examples how to use -files0-from in the manual

Let me know your opinions. ;-)

Shuiqing Zhou <zhoushuiqing>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #53268:  0001-handle-newline.patch added by zhoushuiqing (799B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by berny (Posted a comment)
  • -email is unavailable- added by zhoushuiqing (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-06-02 berny StatusNone Working as Intended
        Assigned toNone berny
        Open/ClosedOpen Closed
    2022-06-02 zhoushuiqing Attached File- Added 0001-handle-newline.patch, #53268

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code