"find" command throws nonsense error message

Bug #1786625 reported by teo1978
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
findutils (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Steps to reproduce:

1. Run this command from a terminal:
$ find . -name *.txt

Expected result:
It should list all the files found in the current directory or any descendant directory whose name ends in ".txt". It may or may not find matching files, depending on whether there are or there aren't.
If there's something wrong in my command, then it should ALWAYS consistently issue a sensible error message explaining what's wrong with my command, and that should happen regardless of the contents of the current directory.

Observed results:
If there are no .txt files to be found, it behaves as expected (i.e., no results, no error message).
If there are files ending in .txt, sometimes it behaves as expected, showing the results.

If, however, there are files ending in ".txt" with dashes ("-") or spaces (" ") in the filename, AND there is more than one file that matches the criteria, then it displays this completely nonsensical error message:
````````````
find: paths must precede expression: XXXXXXXXXXXX.txt
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec|time] [path...] [expression]
````````````
where "XXXXXXXXXXXXX.txt" is an actual filename of a matching file.

For example, this will reproduce the issue:
````````````````````````````
$ echo "lalala" > aaa.txt
$ echo "lololo" > foo-bar.txt
$ find . -name *.txt
find: paths must precede expression: foo-bar.txt
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec|time] [path...] [expression]
````````````````````````````

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: linux-image-4.4.0-131-generic 4.4.0-131.157
ProcVersionSignature: Ubuntu 4.4.0-131.157-generic 4.4.134
Uname: Linux 4.4.0-131-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia
ApportVersion: 2.20.1-0ubuntu2.18
Architecture: amd64
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/controlC0: teo 2898 F.... pulseaudio
CurrentDesktop: Unity
Date: Sat Aug 11 17:30:54 2018
HibernationDevice: RESUME=UUID=ff7e702a-a05a-47fd-8c14-551e81f9e9e3
InstallationDate: Installed on 2013-10-11 (1764 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Release amd64 (20130424)
MachineType: Acer Aspire V3-571G
ProcFB: 0 inteldrmfb
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.4.0-131-generic.efi.signed root=UUID=5830b30e-69e8-4bb4-8a2b-bc2b43c7414a ro quiet splash vt.handoff=7
RelatedPackageVersions:
 linux-restricted-modules-4.4.0-131-generic N/A
 linux-backports-modules-4.4.0-131-generic N/A
 linux-firmware 1.157.20
SourcePackage: linux
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 10/15/2012
dmi.bios.vendor: Acer
dmi.bios.version: V2.07
dmi.board.asset.tag: Type2 - Board Asset Tag
dmi.board.name: VA50_HC_CR
dmi.board.vendor: Acer
dmi.board.version: Type2 - Board Version
dmi.chassis.type: 10
dmi.chassis.vendor: Acer
dmi.chassis.version: V2.07
dmi.modalias: dmi:bvnAcer:bvrV2.07:bd10/15/2012:svnAcer:pnAspireV3-571G:pvrV2.07:rvnAcer:rnVA50_HC_CR:rvrType2-BoardVersion:cvnAcer:ct10:cvrV2.07:
dmi.product.name: Aspire V3-571G
dmi.product.version: V2.07
dmi.sys.vendor: Acer

Revision history for this message
teo1978 (teo8976) wrote :
Revision history for this message
teo1978 (teo8976) wrote :

It's funny that when creating the bug report there was a choice for the package to report against:
- linux
- I don't know.

I chose "I don't know", but it has been assigned to linux allthesame. Brilliant.

no longer affects: linux (Ubuntu)
Revision history for this message
Andreas Metzler (k-launchpad-downhill-at-eu-org) wrote :

Hello,

If you run "find . -name *.txt" in a directory containing foo.txt and bar.txt then the shell expands *.txt before executing find, i.e. you would be running "find . -name foo.txt bar.txt" which produces a syntax error. Either quote ('*.txt') or escape (\*.txt) the argument.

Closing.

Changed in findutils (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.