SCM_CURRENT_USER supports accented characters

`tr 'A-Z' 'a-z'` will only convert non-accented characters. Switching to
`[:upper:]` and `[:lower:]` adds support for accents.
See https://github.com/koalaman/shellcheck/wiki/SC2018

Additionally, printf's character splitting does not support accented
characters, so output isn't as expected. Using bash's variable expansion
syntax instead will correctly get the full accented character.
pull/1018/head
Dan Wendorf 2017-08-06 12:55:46 -07:00
parent 150e82b221
commit c5f2c408e7
2 changed files with 6 additions and 1 deletions

View File

@ -362,6 +362,11 @@ setup_repo_with_upstream() {
git_prompt_vars
assert_equal "$SCM_BRANCH" "${pre} ☺︎ cu"
git config user.name "Çool Üser"
git_prompt_vars
assert_equal "$SCM_BRANCH" "${pre} ☺︎ çü"
# show initials set by `git pair`
git config user.initials "ab cd"

View File

@ -325,7 +325,7 @@ function git_user_info {
# support two or more initials, set by 'git pair' plugin
SCM_CURRENT_USER=$(git config user.initials | sed 's% %+%')
# if `user.initials` weren't set, attempt to extract initials from `user.name`
[[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $(git config user.name | tr 'A-Z' 'a-z'); do printf "%1.1s" $word; done))
[[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $(git config user.name | PERLIO=:utf8 perl -pe '$_=lc'); do printf "%s" "${word:0:1}"; done))
[[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX"
}