Skip to content

Commit

Permalink
Re-wrap functions as functions. Fixes issue with RVM reload (cd wrapp…
Browse files Browse the repository at this point in the history
…er will be overwritten without error)
  • Loading branch information
ndbroadbent committed Jan 30, 2013
1 parent 3692db6 commit dd10be7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/git/shell_shortcuts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e
eval "$(declare -f $cmd | sed -E "s/^$cmd \(\)/__original_$cmd ()/")"
# Remove function
unset -f $cmd
# Create wrapped alias for old function
alias "$cmd"="exec_scmb_expand_args __original_$cmd";;
# Create function that wraps old function
eval "${cmd}(){ exec_scmb_expand_args __original_${cmd} \"\$@\"; }";;

*'is a shell builtin'*)
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is a shell builtin"; fi
Expand Down
3 changes: 2 additions & 1 deletion test/lib/git/shell_shortcuts_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ test_shell_command_wrapping() {
assertAliasEquals "exec_scmb_expand_args /bin/sed" "sed"
assertAliasEquals "exec_scmb_expand_args /bin/cat" "cat"
assertAliasEquals "exec_scmb_expand_args builtin cd" "cd"
assertAliasEquals "exec_scmb_expand_args __original_ln" "ln"
assertIncludes "$(declare -f ln)" "ln ()"
assertIncludes "$(declare -f ln)" "exec_scmb_expand_args __original_ln"
}

test_ls_with_file_shortcuts() {
Expand Down

0 comments on commit dd10be7

Please sign in to comment.