-
Notifications
You must be signed in to change notification settings - Fork 4
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
Update grep.sh #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,18 @@ if ( echo $- | grep i >/dev/null 2>&1 ); then | |
fi | ||
|
||
fi | ||
|
||
my_grep_options=(--color=auto) # I like color, without deprecation warnings | ||
|
||
if ( _version_gte "$( grep -V | head -n 1 | sed 's/[^0-9]*\([0-9]*\.[0-9]*\).*/\1/' )" "2.5.2" ); then | ||
# The following adds new options for grep to exclude: CVS, .cvs, .git, .hg, .svn directories | ||
my_grep_options=( | ||
${my_grep_options[@]} --exclude-dir=CVS) # Excludes CVS directories for CVS | ||
${my_grep_options[@]} --exclude-dir=.cvs) # Excludes .cvs directories for CVS | ||
${my_grep_options[@]} --exclude-dir=.git) # Excludes .git directories for Git | ||
${my_grep_options[@]} --exclude-dir=.hg) # Excludes .hg directories for Mercurial | ||
${my_grep_options[@]} --exclude-dir=.svn) # Excludes .svn directors for Subversion | ||
) | ||
alias grep="grep $my_grep_options" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest using the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow since this conflicts with your initial feedback sir:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I think I see what you mean. Instead of the |
||
unset my_grep_options | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two lines should be outside the if-block so that |
||
fi |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax error, too many closing parenthesis (one per line)
Additionally (if it weren't for the syntax error) this would result in
--color=auto --exclude-dir=CVS --color=auto --exclude-dir=.cvs --color=auto --exclude-dir=.git --color=auto --exclude-dir=.hg --color=auto --exclude-dir=.svn
-- You only need${my_grep_options[@]}
once up-front.