From 3d960a51692a40f99cbf3f4bcdbcb5aa11f0a1f5 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Mon, 5 Nov 2018 02:19:06 +0100 Subject: [PATCH 1/2] Protect users locale --- functions/icons.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/icons.zsh b/functions/icons.zsh index d8661e6f..28cbb709 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -13,6 +13,7 @@ # Initialize the icon list according to the user's `POWERLEVEL9K_MODE`. typeset -gAH icons +() { # add scope to protect the users locale and not overwrite LC_CTYPE! case $POWERLEVEL9K_MODE in 'flat'|'awesome-patched') # Awesome-Patched Font required! See: @@ -528,6 +529,7 @@ esac if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" == true ]]; then icons[VCS_BRANCH_ICON]='' fi +} # Safety function for printing icons # Prints the named icon, or if that icon is undefined, the string name. From 4ebb9f92a1b7e27595db6dd9e05981ac6e0d4bbf Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Wed, 14 Nov 2018 23:27:05 +0100 Subject: [PATCH 2/2] Ensure that LC_CTYPE IS NOT overwritten by P9K --- test/functions/icons.spec | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/test/functions/icons.spec b/test/functions/icons.spec index ec0cb1fa..8083c095 100755 --- a/test/functions/icons.spec +++ b/test/functions/icons.spec @@ -17,52 +17,58 @@ function tearDown() { LC_CTYPE="${_OLD_LC_CTYPE}" } -function testLcCtypeIsSetCorrectlyInDefaultMode() { +function testLcCtypeIsNotOverwrittenInDefaultMode() { local POWERLEVEL9K_MODE="default" + local LC_CTYPE="my-locale" # Load Powerlevel9k source functions/icons.zsh - assertEquals 'en_US.UTF-8' "${LC_CTYPE}" + assertEquals 'my-locale' "${LC_CTYPE}" } -function testLcCtypeIsSetCorrectlyInAwesomePatchedMode() { +function testLcCtypeIsNotOverwrittenInAwesomePatchedMode() { local POWERLEVEL9K_MODE="awesome-patched" + local LC_CTYPE="my-locale" # Load Powerlevel9k source functions/icons.zsh - assertEquals 'en_US.UTF-8' "${LC_CTYPE}" + assertEquals 'my-locale' "${LC_CTYPE}" } -function testLcCtypeIsSetCorrectlyInAwesomeFontconfigMode() { +function testLcCtypeIsNotOverwrittenInAwesomeFontconfigMode() { local POWERLEVEL9K_MODE="awesome-fontconfig" + local LC_CTYPE="my-locale" # Load Powerlevel9k source functions/icons.zsh - assertEquals 'en_US.UTF-8' "${LC_CTYPE}" + assertEquals 'my-locale' "${LC_CTYPE}" } -function testLcCtypeIsSetCorrectlyInNerdfontFontconfigMode() { +function testLcCtypeIsNotOverwrittenInNerdfontFontconfigMode() { local POWERLEVEL9K_MODE="nerdfont-fontconfig" + local LC_CTYPE="my-locale" # Load Powerlevel9k source functions/icons.zsh - assertEquals 'en_US.UTF-8' "${LC_CTYPE}" + assertEquals 'my-locale' "${LC_CTYPE}" } -function testLcCtypeIsSetCorrectlyInFlatMode() { +function testLcCtypeIsNotOverwrittenInFlatMode() { local POWERLEVEL9K_MODE="flat" + local LC_CTYPE="my-locale" # Load Powerlevel9k source functions/icons.zsh - assertEquals 'en_US.UTF-8' "${LC_CTYPE}" + assertEquals 'my-locale' "${LC_CTYPE}" } -function testLcCtypeIsSetCorrectlyInCompatibleMode() { +function testLcCtypeIsNotOverwrittenInCompatibleMode() { local POWERLEVEL9K_MODE="compatible" + local LC_CTYPE="my-locale" # Load Powerlevel9k source functions/icons.zsh - assertEquals 'en_US.UTF-8' "${LC_CTYPE}" + assertEquals 'my-locale' "${LC_CTYPE}" } # Go through all icons defined in default mode, and