Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re-wrap functions as functions. Fixes issue with RVM reload (cd wrapp…

…er will be overwritten without error)
  • Loading branch information...
commit dd10be79e28564b84d0fef0598437baafc79677a 1 parent 3692db6
@ndbroadbent authored
View
4 lib/git/shell_shortcuts.sh
@@ -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
View
3  test/lib/git/shell_shortcuts_test.sh
@@ -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() {
Please sign in to comment.
Something went wrong with that request. Please try again.