Merge pull request #32 from coolluck/master

Avoid bash's variable unbound error
This commit is contained in:
Nathan Broadbent
2012-05-08 17:37:05 -07:00
2 changed files with 6 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ _git
# Usage: __git_alias <alias> <command_prefix> <command> # Usage: __git_alias <alias> <command_prefix> <command>
__git_alias () { __git_alias () {
if [ -n "$1" ]; then if [ -n "$1" ]; then
local alias_str="$1"; local cmd_prefix="$2"; local cmd="$3"; local cmd_args=" $4" local alias_str="$1"; local cmd_prefix="$2"; local cmd="$3"; local cmd_args=" ${4-}"
alias $alias_str="$cmd_prefix $cmd$cmd_args" alias $alias_str="$cmd_prefix $cmd$cmd_args"
if [ "$shell" = "bash" ]; then if [ "$shell" = "bash" ]; then
__define_git_completion $alias_str $cmd __define_git_completion $alias_str $cmd

View File

@@ -22,7 +22,7 @@ git_status_shortcuts() {
# Run ruby script, store output # Run ruby script, store output
local cmd_output="$(/usr/bin/env ruby "$scmbDir/lib/git/status_shortcuts.rb" $@)" local 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
@@ -31,18 +31,18 @@ git_status_shortcuts() {
fi fi
# Fetch list of files from last line of script output # Fetch list of files from last line of script output
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
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
IFS=$' \t\n' IFS=$' \t\n'
if [ "$scmbDebug" = "true" ]; then echo "------------------------"; fi if [ "${scmbDebug:-}" = "true" ]; then echo "------------------------"; fi
# Print status # Print status
echo "$cmd_output" | \grep -v '@@filelist@@::' echo "$cmd_output" | \grep -v '@@filelist@@::'
zsh_reset # Reset zsh environment to default zsh_reset # Reset zsh environment to default
@@ -164,8 +164,7 @@ git_clear_vars() {
local i local i
for (( i=1; i<=$gs_max_changes; i++ )); do for (( i=1; i<=$gs_max_changes; i++ )); do
# Stop clearing after first empty var # Stop clearing after first empty var
if [[ -z "$(eval echo "\$$git_env_char$i")" ]]; then break; fi if [[ -z "$(eval echo "\${$git_env_char$i:-}")" ]]; then break; fi
unset $git_env_char$i
done done
} }