From 904b82bb5835e4257e178314affe9bddc28b8e0c Mon Sep 17 00:00:00 2001 From: DrVanScott Date: Sun, 17 Jul 2016 17:28:34 +0200 Subject: [PATCH] rewrite bash 4 ;;& operator (two step) --- gitstatus.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gitstatus.sh b/gitstatus.sh index e305990..e2b6bce 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -26,17 +26,26 @@ num_conflicts=0 num_untracked=0 while IFS='' read -r line || [[ -n "$line" ]]; do status=${line:0:2} - while true + while [[ -n $status ]] do case "$status" in +#two fixed character matches, loop finished \#\#) branch_line="${line/\.\.\./^}"; break ;; - ?M) ((num_changed++)); status=${status:0:1}"_" ;; - ?D) ((num_changed++)); status=${status:0:1}"_" ;; - U?) ((num_conflicts++)); break ;; \?\?) ((num_untracked++)); break ;; - \ ?) break ;; - *) ((num_staged++)); break ;; + U?) ((num_conflicts++)); break;; + ?U) ((num_conflicts++)); break;; + DD) ((num_conflicts++)); break;; + AA) ((num_conflicts++)); break;; +#two character matches, first loop + ?M) ((num_changed++)) ;; + ?D) ((num_changed++)) ;; + ?\ ) ;; +#single character matches, second loop + U) ((num_conflicts++)) ;; + \ ) ;; + *) ((num_staged++)) ;; esac + status=${status:0:-1} done done <<< "$gitstatus"