Replaced all occurences of 'local IFS=' with 'IFS= ... unset IFS'. Fixes #12
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
git_status_shortcuts() {
|
git_status_shortcuts() {
|
||||||
zsh_compat # Ensure shwordsplit is on for zsh
|
zsh_compat # Ensure shwordsplit is on for zsh
|
||||||
local IFS=$'\n'
|
IFS=$'\n'
|
||||||
local git_status="$(git status --porcelain 2> /dev/null)"
|
local git_status="$(git status --porcelain 2> /dev/null)"
|
||||||
|
|
||||||
if [ -n "$git_status" ] && [[ $(echo "$git_status" | wc -l) -le $gs_max_changes ]]; then
|
if [ -n "$git_status" ] && [[ $(echo "$git_status" | wc -l) -le $gs_max_changes ]]; then
|
||||||
@@ -113,6 +113,7 @@ git_status_shortcuts() {
|
|||||||
# so just use plain 'git status'
|
# so just use plain 'git status'
|
||||||
git status
|
git status
|
||||||
fi
|
fi
|
||||||
|
unset IFS
|
||||||
zsh_reset # Reset zsh environment to default
|
zsh_reset # Reset zsh environment to default
|
||||||
}
|
}
|
||||||
# Template function for 'git_status_shortcuts'.
|
# Template function for 'git_status_shortcuts'.
|
||||||
|
|||||||
@@ -51,11 +51,11 @@
|
|||||||
|
|
||||||
|
|
||||||
function git_index() {
|
function git_index() {
|
||||||
local IFS=$'\n'
|
IFS=$'\n'
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
# Just change to $GIT_REPO_DIR if no params given.
|
# Just change to $GIT_REPO_DIR if no params given.
|
||||||
cd $GIT_REPO_DIR
|
cd $GIT_REPO_DIR
|
||||||
else
|
else
|
||||||
if [ "$1" = "--rebuild" ]; then
|
if [ "$1" = "--rebuild" ]; then
|
||||||
_rebuild_git_index
|
_rebuild_git_index
|
||||||
elif [ "$1" = "--update-all" ]; then
|
elif [ "$1" = "--update-all" ]; then
|
||||||
@@ -74,11 +74,11 @@ function git_index() {
|
|||||||
sed -e "s/\(\([^/]*\/\/\)\?\([^@]*@\)\?\([^:/]*\)\).*/\1/" |
|
sed -e "s/\(\([^/]*\/\/\)\?\([^@]*@\)\?\([^:/]*\)\).*/\1/" |
|
||||||
sort | uniq -c
|
sort | uniq -c
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# If $1 starts with '/', change to top-level directory within $GIT_REPO_DIR
|
# If $1 starts with '/', change to top-level directory within $GIT_REPO_DIR
|
||||||
elif ([ $shell = "bash" ] && [ "${1:0:1}" = "/" ]) || \
|
elif ([ $shell = "bash" ] && [ "${1:0:1}" = "/" ]) || \
|
||||||
([ $shell = "zsh" ] && [ "${1[1]}" = "/" ]); then
|
([ $shell = "zsh" ] && [ "${1[1]}" = "/" ]); then
|
||||||
if [ -d "$GIT_REPO_DIR$1" ]; then cd "$GIT_REPO_DIR$1"; fi
|
if [ -d "$GIT_REPO_DIR$1" ]; then cd "$GIT_REPO_DIR$1"; fi
|
||||||
|
|
||||||
else
|
else
|
||||||
_check_git_index
|
_check_git_index
|
||||||
@@ -112,6 +112,7 @@ function git_index() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
unset IFS
|
||||||
}
|
}
|
||||||
|
|
||||||
_git_index_dirs_without_home() {
|
_git_index_dirs_without_home() {
|
||||||
@@ -121,11 +122,12 @@ _git_index_dirs_without_home() {
|
|||||||
# Recursively searches for git repos in $GIT_REPO_DIR
|
# Recursively searches for git repos in $GIT_REPO_DIR
|
||||||
function _find_git_repos() {
|
function _find_git_repos() {
|
||||||
# Find all unarchived projects
|
# Find all unarchived projects
|
||||||
local IFS=$'\n'
|
IFS=$'\n'
|
||||||
for repo in $(find "$GIT_REPO_DIR" -maxdepth 4 -name ".git" -type d \! -wholename '*/archive/*'); do
|
for repo in $(find "$GIT_REPO_DIR" -maxdepth 4 -name ".git" -type d \! -wholename '*/archive/*'); do
|
||||||
echo ${repo%/.git} # Return project folder, with trailing ':'
|
echo ${repo%/.git} # Return project folder, with trailing ':'
|
||||||
_find_git_submodules $repo # Detect any submodules
|
_find_git_submodules $repo # Detect any submodules
|
||||||
done
|
done
|
||||||
|
unset IFS
|
||||||
}
|
}
|
||||||
|
|
||||||
# List all submodules for a git repo, if any.
|
# List all submodules for a git repo, if any.
|
||||||
@@ -140,10 +142,11 @@ function _find_git_submodules() {
|
|||||||
function _rebuild_git_index() {
|
function _rebuild_git_index() {
|
||||||
if [ "$1" != "--silent" ]; then echo -e "== Scanning $GIT_REPO_DIR for git repos & submodules..."; fi
|
if [ "$1" != "--silent" ]; then echo -e "== Scanning $GIT_REPO_DIR for git repos & submodules..."; fi
|
||||||
# Get repos from src dir and custom dirs, then sort by basename
|
# Get repos from src dir and custom dirs, then sort by basename
|
||||||
local IFS=$'\n'
|
IFS=$'\n'
|
||||||
for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do
|
for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do
|
||||||
echo $(basename $repo | sed "s/ /_/g") $repo
|
echo $(basename $repo | sed "s/ /_/g") $repo
|
||||||
done | sort | cut -d " " -f2- > "$GIT_REPO_DIR/.git_index"
|
done | sort | cut -d " " -f2- > "$GIT_REPO_DIR/.git_index"
|
||||||
|
unset IFS
|
||||||
|
|
||||||
if [ "$1" != "--silent" ]; then
|
if [ "$1" != "--silent" ]; then
|
||||||
echo -e "===== Indexed $_bld_col$(_git_index_count)$_txt_col repos in $GIT_REPO_DIR/.git_index"
|
echo -e "===== Indexed $_bld_col$(_git_index_count)$_txt_col repos in $GIT_REPO_DIR/.git_index"
|
||||||
@@ -227,7 +230,7 @@ function _git_index_batch_cmd() {
|
|||||||
function _git_index_tab_completion() {
|
function _git_index_tab_completion() {
|
||||||
_check_git_index
|
_check_git_index
|
||||||
local curw
|
local curw
|
||||||
local IFS=$'\n'
|
IFS=$'\n'
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
curw=${COMP_WORDS[COMP_CWORD]}
|
curw=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
|
||||||
@@ -240,17 +243,18 @@ function _git_index_tab_completion() {
|
|||||||
if [[ -n "$base_path" && $curw == */* ]]; then
|
if [[ -n "$base_path" && $curw == */* ]]; then
|
||||||
local search_path=$(echo "$curw" | sed "s:^${project/\\/\\\\\\}::")
|
local search_path=$(echo "$curw" | sed "s:^${project/\\/\\\\\\}::")
|
||||||
COMPREPLY=($(compgen -d "$base_path$search_path" | grep -v "/.git" | sed -e "s:$base_path:$project:" -e "s:$:/:" ))
|
COMPREPLY=($(compgen -d "$base_path$search_path" | grep -v "/.git" | sed -e "s:$base_path:$project:" -e "s:$:/:" ))
|
||||||
|
|
||||||
# If curr string starts with /, tab complete top-level directories in root project dir
|
# If curr string starts with /, tab complete top-level directories in root project dir
|
||||||
elif ([ $shell = "bash" ] && [ "${curw:0:1}" = "/" ]) || \
|
elif ([ $shell = "bash" ] && [ "${curw:0:1}" = "/" ]) || \
|
||||||
([ $shell = "zsh" ] && [ "${curw[1]}" = "/" ]); then
|
([ $shell = "zsh" ] && [ "${curw[1]}" = "/" ]); then
|
||||||
COMPREPLY=($(compgen -d "$GIT_REPO_DIR$curw" | sed -e "s:$GIT_REPO_DIR/::" -e "s:^:/:"))
|
COMPREPLY=($(compgen -d "$GIT_REPO_DIR$curw" | sed -e "s:$GIT_REPO_DIR/::" -e "s:^:/:"))
|
||||||
|
|
||||||
# Else, tab complete the entries in .git_index, plus '--' commands
|
# Else, tab complete the entries in .git_index, plus '--' commands
|
||||||
else
|
else
|
||||||
local commands="--list\n--rebuild\n--update-all\n--batch-cmd\n--count-by-host"
|
local commands="--list\n--rebuild\n--update-all\n--batch-cmd\n--count-by-host"
|
||||||
COMPREPLY=($(compgen -W '$(sed -e "s:.*/::" -e "s:$:/:" "$GIT_REPO_DIR/.git_index" | sort)$(echo -e "\n"$commands)' -- $curw))
|
COMPREPLY=($(compgen -W '$(sed -e "s:.*/::" -e "s:$:/:" "$GIT_REPO_DIR/.git_index" | sort)$(echo -e "\n"$commands)' -- $curw))
|
||||||
fi
|
fi
|
||||||
|
unset IFS
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ git_status_shortcuts() {
|
|||||||
# Run ruby script, store output
|
# Run ruby script, store output
|
||||||
cmd_output=$(/usr/bin/env ruby "$scmbDir/lib/git/status_shortcuts.rb" $@)
|
cmd_output=$(/usr/bin/env ruby "$scmbDir/lib/git/status_shortcuts.rb" $@)
|
||||||
# Print debug information if $scmbDebug = "true"
|
# Print debug information if $scmbDebug = "true"
|
||||||
if [ "$scmbDebug" = "true" ]; then
|
if [ "$scmbDebug" = "true" ]; then
|
||||||
printf "status_shortcuts.rb output => \n$cmd_output\n------------------------\n"
|
printf "status_shortcuts.rb output => \n$cmd_output\n------------------------\n"
|
||||||
fi
|
fi
|
||||||
if [[ -z "$cmd_output" ]]; then
|
if [[ -z "$cmd_output" ]]; then
|
||||||
@@ -33,13 +33,14 @@ git_status_shortcuts() {
|
|||||||
files="$(echo "$cmd_output" | grep '@@filelist@@::' | sed 's%@@filelist@@::%%g')"
|
files="$(echo "$cmd_output" | grep '@@filelist@@::' | sed 's%@@filelist@@::%%g')"
|
||||||
if [ "$scmbDebug" = "true" ]; then echo "filelist => $files"; fi
|
if [ "$scmbDebug" = "true" ]; then echo "filelist => $files"; fi
|
||||||
# Export numbered env variables for each file
|
# Export numbered env variables for each file
|
||||||
local IFS="|"
|
IFS="|"
|
||||||
local e=1
|
local e=1
|
||||||
for file in $files; do
|
for file in $files; do
|
||||||
export $git_env_char$e="$file"
|
export $git_env_char$e="$file"
|
||||||
if [ "$scmbDebug" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi
|
if [ "$scmbDebug" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi
|
||||||
let e++
|
let e++
|
||||||
done
|
done
|
||||||
|
unset IFS
|
||||||
|
|
||||||
if [ "$scmbDebug" = "true" ]; then echo "------------------------"; fi
|
if [ "$scmbDebug" = "true" ]; then echo "------------------------"; fi
|
||||||
# Print status
|
# Print status
|
||||||
@@ -112,11 +113,12 @@ git_add_patch_shortcuts() {
|
|||||||
git_silent_add_patch_shortcuts() {
|
git_silent_add_patch_shortcuts() {
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
# Expand args and process resulting set of files.
|
# Expand args and process resulting set of files.
|
||||||
local IFS=$'\n'
|
IFS=$'\n'
|
||||||
eval for file in $(git_expand_args "$@")\; do\
|
eval for file in $(git_expand_args "$@")\; do\
|
||||||
git add -p "\$file"\;\
|
git add -p "\$file"\;\
|
||||||
echo -e "# add '\$file'"\;\
|
echo -e "# add '\$file'"\;\
|
||||||
done
|
done
|
||||||
|
unset IFS
|
||||||
echo "#"
|
echo "#"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ EOF
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Setup some custom repos outside the main repo dir
|
# Setup some custom repos outside the main repo dir
|
||||||
local IFS=":"
|
IFS=":"
|
||||||
for dir in $GIT_REPOS; do
|
for dir in $GIT_REPOS; do
|
||||||
mkdir -p $dir; cd $dir; git init;
|
mkdir -p $dir; cd $dir; git init;
|
||||||
done
|
done
|
||||||
@@ -72,8 +72,9 @@ EOF
|
|||||||
|
|
||||||
oneTimeTearDown() {
|
oneTimeTearDown() {
|
||||||
rm -rf "${GIT_REPO_DIR}"
|
rm -rf "${GIT_REPO_DIR}"
|
||||||
local IFS=":"
|
IFS=":"
|
||||||
for dir in $GIT_REPOS; do rm -rf $dir; done
|
for dir in $GIT_REPOS; do rm -rf $dir; done
|
||||||
|
unset IFS
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureIndex() {
|
ensureIndex() {
|
||||||
|
|||||||
Reference in New Issue
Block a user