Substitute all grep instances with command grep

This commit is contained in:
Giuseppe Rota
2012-04-26 17:27:50 +02:00
parent 843a662149
commit cc48bcb82f

View File

@@ -69,7 +69,7 @@ function git_index() {
done | sort | column -t -s ':' done | sort | column -t -s ':'
elif [ "$1" = "--count-by-host" ]; then elif [ "$1" = "--count-by-host" ]; then
echo -e "=== Producing a report of the number of repos per host...\n" echo -e "=== Producing a report of the number of repos per host...\n"
_git_index_batch_cmd git remote -v | grep "origin.*(fetch)" | _git_index_batch_cmd git remote -v | command grep "origin.*(fetch)" |
sed -e "s/origin\s*//" -e "s/(fetch)//" | sed -e "s/origin\s*//" -e "s/(fetch)//" |
sed -e "s/\(\([^/]*\/\/\)\?\([^@]*@\)\?\([^:/]*\)\).*/\1/" | sed -e "s/\(\([^/]*\/\/\)\?\([^@]*@\)\?\([^:/]*\)\).*/\1/" |
sort | uniq -c sort | uniq -c
@@ -85,7 +85,7 @@ function git_index() {
# Figure out which directory we need to change to. # Figure out which directory we need to change to.
local project=$(echo $1 | cut -d "/" -f1) local project=$(echo $1 | cut -d "/" -f1)
# Find base path of project # Find base path of project
local base_path="$(grep -m1 "/$project$" "$GIT_REPO_DIR/.git_index")" local base_path="$(command grep -m1 "/$project$" "$GIT_REPO_DIR/.git_index")"
if [ -n "$base_path" ]; then if [ -n "$base_path" ]; then
sub_path=$(echo $1 | sed "s:^$project::") sub_path=$(echo $1 | sed "s:^$project::")
# Append subdirectories to base path # Append subdirectories to base path
@@ -93,9 +93,9 @@ function git_index() {
fi fi
# Try partial matches # Try partial matches
# - string at beginning of project # - string at beginning of project
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | grep -m1 "/$project"); fi if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | command grep -m1 "/$project"); fi
# - string anywhere in project # - string anywhere in project
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | grep -m1 "$project"); fi if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | command grep -m1 "$project"); fi
# -------------------- # --------------------
# Go to our base path # Go to our base path
if [ -n "$base_path" ]; then if [ -n "$base_path" ]; then
@@ -133,7 +133,7 @@ function _find_git_repos() {
# List all submodules for a git repo, if any. # List all submodules for a git repo, if any.
function _find_git_submodules() { function _find_git_submodules() {
if [ -e "$1/../.gitmodules" ]; then if [ -e "$1/../.gitmodules" ]; then
grep "\[submodule" "$1/../.gitmodules" | sed "s%\[submodule \"%${1%/.git}/%g" | sed "s/\"]//g" command grep "\[submodule" "$1/../.gitmodules" | sed "s%\[submodule \"%${1%/.git}/%g" | sed "s/\"]//g"
fi fi
} }
@@ -162,7 +162,7 @@ function _check_git_index() {
# Produces a count of repos in the tab completion index (excluding commands) # Produces a count of repos in the tab completion index (excluding commands)
function _git_index_count() { function _git_index_count() {
echo $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | grep . | wc -l) echo $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | command grep . | wc -l)
} }
# Returns the current git branch (returns nothing if not a git repository) # Returns the current git branch (returns nothing if not a git repository)
@@ -174,7 +174,7 @@ parse_git_branch() {
function _git_index_status_if_dirty() { function _git_index_status_if_dirty() {
if ! [ `git status --porcelain | wc -l` -eq 0 ]; then if ! [ `git status --porcelain | wc -l` -eq 0 ]; then
# Fall back to 'git status' if git status alias isn't configured # Fall back to 'git status' if git status alias isn't configured
if type $git_status_command 2>&1 | grep -qv "not found"; then if type $git_status_command 2>&1 | command grep -qv "not found"; then
eval $git_status_command eval $git_status_command
else else
git status git status
@@ -263,7 +263,7 @@ function _git_index_batch_cmd() {
echo -e "== Running command for $_bld_col$(_git_index_count)$_txt_col repos...\n" echo -e "== Running command for $_bld_col$(_git_index_count)$_txt_col repos...\n"
IFS=$' \t\n' IFS=$' \t\n'
local base_path local base_path
for base_path in $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | grep . | sort); do for base_path in $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | command grep . | sort); do
builtin cd "$base_path" builtin cd "$base_path"
$@ $@
done done
@@ -285,7 +285,7 @@ function _git_index_tab_completion() {
# If the first part of $curw matches a high-level directory, # If the first part of $curw matches a high-level directory,
# then match on sub-directories for that project # then match on sub-directories for that project
local project=$(echo "$curw" | cut -d "/" -f1) local project=$(echo "$curw" | cut -d "/" -f1)
local base_path=$(grep "/$project$" "$GIT_REPO_DIR/.git_index" | sed 's/ /\\ /g') local base_path=$(command grep "/$project$" "$GIT_REPO_DIR/.git_index" | sed 's/ /\\ /g')
# If matching project path was found and curr string contains a /, then complete project sub-directories # If matching project path was found and curr string contains a /, then complete project sub-directories
if [[ -n "$base_path" && $curw == */* ]]; then if [[ -n "$base_path" && $curw == */* ]]; then