return to the previous directory after fetching/updating nvm#1144
Conversation
| printf "\r=> " | ||
| cd "$INSTALL_DIR" && (command git fetch 2> /dev/null || { | ||
| pushd "$INSTALL_DIR" && (command git fetch 2> /dev/null || { | ||
| echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself." && exit 1 |
There was a problem hiding this comment.
if this condition triggers, won't the directory still be changed?
It seems like if we're going to popd when things work, we should do it in all the failure cases too.
There was a problem hiding this comment.
I'm beginning to think that we could get rid of cd and friends altogether. Instead use the --git-dir and --work-tree options for the git commands.
What do you think?
There was a problem hiding this comment.
I think I like that better, provided that those commands were supported in an old enough version of git that it won't suddenly raise the threshold for required git support.
There was a problem hiding this comment.
git-1.8.2.3.tar.bz2 (09-May-2013) as available on https://www.kernel.org/pub/software/scm/git/ supports those options. Does that appear old enough or do we want to dig further?
There was a problem hiding this comment.
Appears that the options existed much prior to that. See https://git-scm.com/blog/2010/04/11/environment.html
|
This LGTM, pending a rebase down to 1 commit, assuming that we can't get away with omitting the "git dir" arg entirely |
Fixes #1136