Replaced all occurences of 'local IFS=' with 'IFS= ... unset IFS'. Fixes #12

This commit is contained in:
Nathan Broadbent
2011-12-14 13:27:39 +08:00
parent 2cd411aa4f
commit 993c9ee9fc
4 changed files with 27 additions and 19 deletions

View File

@@ -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'.

View File

@@ -51,7 +51,7 @@
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
@@ -78,7 +78,7 @@ function git_index() {
# 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]}
@@ -241,16 +244,17 @@ function _git_index_tab_completion() {
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
}

View File

@@ -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
}

View File

@@ -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() {