From fdfe1fe72f8fe358d2b64ddc9e1b58dda4d3ba90 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 6 Jun 2015 14:54:33 +1200 Subject: Separate declaration from assignment --- bash/bashrc.d/prompt.bash | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'bash/bashrc.d/prompt.bash') diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index f4a1b718..fa46a5dd 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -95,7 +95,7 @@ prompt() { # Safely read status with -z --porcelain local line - local -i ready=0 modified=0 untracked=0 + local -i ready modified untracked while IFS= read -r -d '' line ; do if [[ $line == [MADRCT]* ]] ; then ready=1 @@ -126,8 +126,7 @@ prompt() { fi # Print the status in brackets with a git: prefix - local IFS= - printf '(git:%s%s)' "${branch:-unknown}" "${state[*]}" + (IFS= ; printf '(git:%s%s)' "${branch:-unknown}" "${state[*]}") ;; # Mercurial prompt function @@ -148,7 +147,7 @@ prompt() { # Safely read status with -0 local line - local -i modified=0 untracked=0 + local -i modified untracked while IFS= read -r -d '' line ; do if [[ $line == '?'* ]] ; then untracked=1 @@ -167,8 +166,7 @@ prompt() { fi # Print the status in brackets with an hg: prefix - local IFS= - printf '(hg:%s%s)' "${branch:-unknown}" "${state[*]}" + (IFS= ; printf '(hg:%s%s)' "${branch:-unknown}" "${state[*]}") ;; # Subversion prompt function @@ -207,7 +205,7 @@ prompt() { # Parse the output of svn status to determine working copy state local symbol - local -i modified=0 untracked=0 + local -i modified untracked while read -r symbol _ ; do if [[ $symbol == *'?'* ]] ; then untracked=1 @@ -226,8 +224,7 @@ prompt() { fi # Print the state in brackets with an svn: prefix - local IFS= - printf '(svn:%s%s)' "${branch:-unknown}" "${state[*]}" + (IFS= ; printf '(svn:%s%s)' "${branch:-unknown}" "${state[*]}") ;; # VCS wrapper prompt function; print the first relevant prompt, if any @@ -244,7 +241,7 @@ prompt() { # Show the count of background jobs in curly brackets, if not zero job) - local -i jobc=0 + local -i jobc while read -r _ ; do ((jobc++)) done < <(jobs -p) -- cgit v1.2.3