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