From 3a39926b86c17a7c14f04598c8bae382e7e7c019 Mon Sep 17 00:00:00 2001 From: Nathan Daly Date: Sun, 21 Aug 2016 12:47:45 -0500 Subject: [PATCH] Now outputs git pull status when updating plugins. Removed pipe to /dev/null for $(pull_changes $plugin). Part of #76. At least for now, I've formatted the output to look like the below paste. This shows a failed, no-op success, and pull success: =================================================== Updating all plugins! Updating "tpm" | There is no tracking information for the current branch. | Please specify which branch you want to merge with. | See git-pull(1) for details. | | git pull | | If you wish to set tracking information for this branch you can do so with: | | git branch --set-upstream-to=/ nhdaly_update_output "tpm" update fail Updating "tmux-sensible" | Already up-to-date. "tmux-sensible" update success Updating "tmux-scroll-copy-mode" | Updating 1ee5602..5e4c864 | Fast-forward | README.md | 5 +++-- | scroll_copy_mode.tmux | 8 +++++--- | 2 files changed, 8 insertions(+), 5 deletions(-) "tmux-scroll-copy-mode" update success --- scripts/update_plugin.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/update_plugin.sh b/scripts/update_plugin.sh index d923d83..d4fd956 100755 --- a/scripts/update_plugin.sh +++ b/scripts/update_plugin.sh @@ -25,12 +25,28 @@ pull_changes() { GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive } +print_update_status() { + # Indent and format the output from the update command. + local plugin="$1" + local update_output=$(echo "$2" | awk '{print " | "$0}') + local update_status=$3 + + if [ $update_status == "0" ]; then + echo_ok "$update_output\n \"$plugin\" update success" + echo_ok + else + echo_err "$update_output\n \"$plugin\" update fail" + echo_err + fi +} + update() { local plugin="$1" echo_ok "Updating \"$plugin\"" - $(pull_changes "$plugin" > /dev/null 2>&1) && - echo_ok " \"$plugin\" update success" || - echo_err " \"$plugin\" update fail" + # Note, this cannot be a local variable, since that seems to supress the $? from being set. + update_output=$(pull_changes "$plugin" 2>&1); + local update_status="$?" + $(print_update_status "$plugin" "$update_output" "$update_status") } update_all() {