#38 Locate fails if some file names contain special characters
Closed: Invalid Opened by karlkastner.

This bug is an upstream report from Ubuntu bug #1587101.

Locate fails to find files if some file names contain special characters. Locate does not only fail on the particular files containing special characters, but also on files with similar names. On my system there is a large set of PDF-files that was automatically named with titles parsed from within the files. Some of these titles contain ligatures or other special characters. Off course, one could rename all files with special characters, but this is tedious. Locate should work correctly in the first place. The reason that locate is not working correctly is that locate probably uses grep without supplying the "-a" option. This is inherently unsafe. Without the "-a" option grep goes into binary mode whenever a special character is encountered. In binary mode grep does not any more print the matched lines, but only "Binary file matches". Someone who knows the code should be able to fix this on the fly.


Example:

pia@pia-W230SS:~$ locate вода

Binary file (standard input) matches

pia@pia-W230SS:~$ find /home/pia/phd/ | \grep вода

Binary file (standard input) matches

pia@pia-W230SS:~$ find /home/pia/phd/ | \grep -a вода

/home/pia/phd/literature/all/�а��е��-п�иливов-в-�ека�-и-п�иб�ежн��-вода�-д�онке��.pdf

Binary file (standard input) matches

What version of locate is this? Please paste the output of locate --version.

mlocate does not use grep at all and does not contain the above message either.

0.26 as stated in the bug report.
{{{
locate --version
mlocate 0.26
Copyright (C) 2007 Red Hat, Inc. All rights reserved.
This software is distributed under the GPL v.2.

This program is provided with NO WARRANTY, to the extent permitted by law.

dpkg -l mlocate
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===============================================-============================-============================-===================================================================================================
ii mlocate 0.26-1ubuntu2 amd64 quickly find files on the filesystem based on their name

}}}

That’s… really quite impossible AFAICT. Could you have two different locates in different PATHs?
strace -ff might help, perhaps.

Indeed, there was an unhygienic alias.

Metadata