Skip to content

Commit 10df8f8

Browse files
author
Noah Gorny
committed
helpers: Improve pull_and_update_inner by restoring old pwd
1 parent caec973 commit 10df8f8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/helpers.bash

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ _bash-it-update-stable() {
195195
}
196196

197197
_bash-it_pull_and_update_inner() {
198+
_param '1: Which branch to checkout to'
199+
_param '2: Which type of version we are using'
200+
_param '3: Old pwd to restore'
198201
git checkout "$1" &> /dev/null
199202
if [[ $? -eq 0 ]]; then
200203
echo "Bash-it successfully updated."
@@ -203,7 +206,9 @@ _bash-it_pull_and_update_inner() {
203206
_bash-it-migrate
204207
echo ""
205208
echo "All done, enjoy!"
206-
bash-it restart
209+
# Don't forget to restore the original pwd!
210+
cd "$3" &> /dev/null
211+
_bash-it-restart
207212
else
208213
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
209214
fi
@@ -284,12 +289,12 @@ _bash-it-update-() {
284289

285290
if [[ $silent ]]; then
286291
echo "Updating to ${TARGET}($(git log -1 --format=%h "${TARGET}"))..."
287-
_bash-it_pull_and_update_inner $TARGET $version
292+
_bash-it_pull_and_update_inner $TARGET $version $old_pwd
288293
else
289294
read -e -n 1 -p "Would you like to update to ${TARGET}($(git log -1 --format=%h "${TARGET}"))? [Y/n] " RESP
290295
case $RESP in
291296
[yY]|"")
292-
_bash-it_pull_and_update_inner $TARGET $version
297+
_bash-it_pull_and_update_inner $TARGET $version $old_pwd
293298
;;
294299
[nN])
295300
echo "Not updating…"

0 commit comments

Comments
 (0)