Menu

#580 Grep: Multiple issues: grep -r something *.js gives error if JS files are not in current directory, and version 2.4.2 is in the zip file saying it's supposed to be 2.5.4.

Grep
open
nobody
None
5
2022-01-16
2022-01-16
Maelstorm
No

Grep 2.4.2 on Windows 10 Professional x64

C:\Servers\webdocs\core\js\baseline>grep -rni restagmain *.js
header.js:133:          $('#restagmain').css('top', heightAcc);
header.js:134:          $('#restagmain').css('height', heightMsgArea);

C:\Servers\webdocs\core\js\baseline>cd ..

C:\Servers\webdocs\core\js>grep -rni restagmain *.js
grep: *.js: No such file or directory

C:\Servers\webdocs\core\js>grep --version
GNU grep 2.5.4

Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


C:\Servers\webdocs\core\js>

The problem is that grep is showing invalid behavior when the -r switch is used. What it SHOULD do is if the -r switch is present, search the subdirectories for the specified files before giving that error message if no JS files are found in the directory tree.

Additionally, the wrong version is for download on the site http://gnuwin32.sourceforge.net/packages/grep.htm. In the zip binary download, grep reports that it's version 2.4.2 even though the zip file is grep-2.5.4-bin.zip.

Discussion

MongoDB Logo MongoDB