@@ -194,7 +194,10 @@ _bash-it-update-stable() {
194194 _bash-it-update- stable " $@ "
195195}
196196
197- _bash-it_pull_and_update_inner () {
197+ _bash-it_update_migrate_and_restart () {
198+ _about ' Checks out the wanted version, pops directory and restart. Does not return (because of the restart!)'
199+ _param ' 1: Which branch to checkout to'
200+ _param ' 2: Which type of version we are using'
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+ popd & > /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
@@ -220,9 +225,8 @@ _bash-it-update-() {
220225 silent=true
221226 fi
222227 done
223- local old_pwd=" ${PWD} "
224228
225- cd " ${BASH_IT} " || return
229+ pushd " ${BASH_IT} " & > /dev/null || return
226230
227231 DIFF=$( git diff --name-status)
228232 [ -n " $DIFF " ] && echo -e " Local changes detected in bash-it directory. Clean '$BASH_IT ' directory to proceed.\n$DIFF " && return 1
@@ -243,7 +247,7 @@ _bash-it-update-() {
243247
244248 if [[ -z " $TARGET " ]]; then
245249 echo " Can not find tags, so can not update to latest stable version..."
246- cd " ${old_pwd} " & > /dev/null
250+ popd & > /dev/null
247251 return
248252 fi
249253 else
@@ -284,12 +288,12 @@ _bash-it-update-() {
284288
285289 if [[ $silent ]]; then
286290 echo " Updating to ${TARGET} ($( git log -1 --format=%h " ${TARGET} " ) )..."
287- _bash-it_pull_and_update_inner $TARGET $version
291+ _bash-it_update_migrate_and_restart $TARGET $version
288292 else
289293 read -e -n 1 -p " Would you like to update to ${TARGET} ($( git log -1 --format=%h " ${TARGET} " ) )? [Y/n] " RESP
290294 case $RESP in
291295 [yY]|" " )
292- _bash-it_pull_and_update_inner $TARGET $version
296+ _bash-it_update_migrate_and_restart $TARGET $version
293297 ;;
294298 [nN])
295299 echo " Not updating…"
@@ -306,7 +310,7 @@ _bash-it-update-() {
306310 echo " Bash-it is up to date, nothing to do!"
307311 fi
308312 fi
309- cd " ${old_pwd} " & > /dev/null || return
313+ popd & > /dev/null
310314}
311315
312316_bash-it-migrate () {
0 commit comments