From 0324b118ee03b2bfe19f0f9cc91d163c83d2c487 Mon Sep 17 00:00:00 2001 From: Mathias Lafeldt Date: Mon, 14 Nov 2011 21:45:43 +0100 Subject: [PATCH 1/2] rbenv-rehash: remove superfluous trap signals A trap on the special signal EXIT is executed before the shell terminates. EXIT actually covers SIGINT and SIGTERM as well, and we don't need any extra traps for them. See bash(1) and "help trap" in bash. --- libexec/rbenv-rehash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rbenv-rehash b/libexec/rbenv-rehash index cb7713ef..8bdf7ed2 100755 --- a/libexec/rbenv-rehash +++ b/libexec/rbenv-rehash @@ -22,7 +22,7 @@ set +o noclobber # If we were able to obtain a lock, register a trap to clean up the # prototype shim when the process exits. -trap remove_prototype_shim SIGINT SIGTERM EXIT +trap remove_prototype_shim EXIT remove_prototype_shim() { rm -f "$PROTOTYPE_SHIM_PATH" From 9dde161b652b31185966accb225a5f05b4643704 Mon Sep 17 00:00:00 2001 From: Mathias Lafeldt Date: Mon, 14 Nov 2011 22:07:41 +0100 Subject: [PATCH 2/2] rbenv-rehash: use $OLDPWD to restore previous working directory $OLDPWD is a standard shell variable that contains the previous working directory as set by the "cd" command. No need to save $PWD to some custom variable. (We could also have used "cd -" but it prints out $OLDPWD too.) --- libexec/rbenv-rehash | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libexec/rbenv-rehash b/libexec/rbenv-rehash index 8bdf7ed2..13f9b1cf 100755 --- a/libexec/rbenv-rehash +++ b/libexec/rbenv-rehash @@ -55,9 +55,6 @@ make_shims() { done } -# Save the working directory. -CUR_PATH=$PWD - # Empty out the shims directory and make it the working directory. rm -f "$SHIM_PATH"/* cd "$SHIM_PATH" @@ -68,7 +65,7 @@ shopt -s nullglob make_shims ../versions/*/bin/* # Restore the previous working directory. -cd "$CUR_PATH" +cd "$OLDPWD" for script in $(rbenv-hooks rehash); do source "$script"