diff --git a/Scripts/Bash/Functions/cli_getRepoStatus.sh b/Scripts/Bash/Functions/cli_getRepoStatus.sh index c1540ef..330b4d8 100755 --- a/Scripts/Bash/Functions/cli_getRepoStatus.sh +++ b/Scripts/Bash/Functions/cli_getRepoStatus.sh @@ -31,6 +31,11 @@ function cli_getRepoStatus { local FILE="$1" local STATUS='' + # Define regular expression pattern to retrive first column, + # returned by subversion status command. This column is one + # character column as describes `svn help status' command. + local PATTERN="^( |A|C|D|I|M|R|X|\?|!|~]).+$" + # Verify the file used as source to retrive its status # information. We only use regular files or directories inside the # working copy. @@ -38,7 +43,21 @@ function cli_getRepoStatus { # Use subversion `status' command to retrive the first character # in the output. - STATUS=$(svn status "$FILE" --quiet | sed -r 's/^( |A|C|D|I|M|R|X|\?|!|~]).+/\1/' ) + STATUS="$(svn status "$FILE" --quiet | sed -r "s/${PATTER}/\1/")" + + # Sanitate status output. + if [[ "$STATUS" == '' ]];then + # If status is empty, there is no output error and we assume + # file being checked doesn't have changes either, so redefine + # status as `no modification'. + STATUS=' ' + elif [[ ! "$STATUS" =~ "$PATTERN" ]];then + # If status doesn't match the regular expression pattern + # defined previusly, we assume file being checked is not under + # version control, so we redefine status as `item is not under + # version control'. + STATUS='?' + fi # Outout status information. echo -n "$STATUS"