hg: remove usage of tail+awk in favor of sed

This commit is contained in:
Olivier Mengué 2014-01-19 19:56:00 +01:00
parent 8df6cffef7
commit a201e152f7

View File

@ -847,7 +847,8 @@ _lp_hg_branch_color()
fi
else
local has_lines
has_lines=$(hg diff --stat 2>/dev/null | tail -n 1 | awk 'FS=" " {printf("+%s/-%s\n", $4, $6)}')
# Parse the last line of the diffstat-style output
has_lines="$(hg diff --stat 2>/dev/null | sed -n '$ s!^.*, \([0-9]*\) .*, \([0-9]*\).*$!+\1/-\2!p')"
if (( commits > 0 )) ; then
# Changes to commit and commits to push
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$commits${NO_COL})${has_untracked}${NO_COL}"