-
-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grep Option Error #1
Comments
Here is the fork: http://github.com/earthgecko/graudit/blob/6b38597185dbd4033b54b0e63b75141b1d6f41b1/graudit Nice work by the way, I like it a lot already... so much so that I decided |
As wireghoul has pointed out this grep exclude option does not work. It only works on filenames, not directory paths. I think I may have found a lovely poetic way to solve it. Working on it now, but will take a while to test this time :) |
A grep version "workaround" has been found and commited to http://github.com/earthgecko/graudit/blob/2ff761c894509a9ffb7c3dfdd6a5e1731a8f202f/graudit sorry I have still not got this github sussed yet.
This has been tested against .svn, .cvs and .git directories and works. However, for clients running an older version of grep than 2.5.3, the methodology of the main grep is changed and .svn, .cvs and .git directories ARE grepped through, but any results from those directories are then excluded via a grep -v (so do not match). Further to this the resultant orphaned separator lines need to be cleaned up as well and all separator lines followed by another separator line are both removed. Just a brief breakdown of the additions for older clients:
Piping the output through grep again to remove any lines that include a /.svn/ with anything following until a number and : or - is encountered. This should overcome any edge cases where the code has a potential security flaw and the author has also ended the line with a comment that references a /.svn/ path, extreme edge case but.. This should overcome that by having the line include the graudit output format with the line number enclosed in colons (:) or minuses (-).
Due to this methodology now essentially including .svn, .cvs and .git dirs and THEN removing them, it leaves multiple graudit separator lines in the output, for .svn, .cvs or .git lines that have been removed. Here we check if the line ends in a # and if not we skip it. If the line ends with a # and we fetch the next line and put them together. If the combined two lines match this pattern (end with a #), we delete them. As for the grep version check it should be good until the release of version 2.6 :) It is not the nicest or neatest workaround in the world, but... it is not the simplest problem either :) At least it would get graudit working with all grep clients straight away. Hopefully not missed anything this time. |
Just to let you know that the version of grep that I am using does not have --exclude-dir option in this version. Below is the output from running graudit.
Having looked through the code you may want to consider using just the grep --exclude option and passing a regex of the svn cvs and git dirs. This should achieve the same thing.
So passing grep the following:
Have made the modification to graudit and tested it on my version and those option parameters are working, so I will fork the file and update this issue.
The text was updated successfully, but these errors were encountered: