From 874dfd4c86c459d0df75d94c69ac0bcb9f1e8567 Mon Sep 17 00:00:00 2001 From: Sebastian Riedel Date: Sat, 8 Sep 2018 06:11:50 +0200 Subject: [PATCH] Replace ~ only outside of variables --- GBM/Managers/mgrPath.vb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/GBM/Managers/mgrPath.vb b/GBM/Managers/mgrPath.vb index 88fa2ab..4fd8ce3 100644 --- a/GBM/Managers/mgrPath.vb +++ b/GBM/Managers/mgrPath.vb @@ -343,8 +343,9 @@ Public Class mgrPath Dim sEnvCurrentUser As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) If mgrCommon.IsUnix Then - Dim oParse As new Regex("\$([a-zA-Z0-9_]+?)") + Dim oParse As new Regex("\$([a-zA-Z0-9_]+)") Dim oParseBracketed As new Regex("\$\{([a-zA-Z0-9_]+?)\}") + Dim oParseTilde As new Regex("~(?![^\$\{]*\})") If sEnvCurrentUser = String.Empty Then 'Fall back sEnvCurrentUser = Environment.GetFolderPath(Environment.SpecialFolder.Personal) @@ -357,7 +358,8 @@ Public Class mgrPath '$HOME to ${HOME} sValue = oParse.Replace(sValue, "${$1}") 'Special notations for home directory - sValue = sValue.Replace("~", "${HOME}") + 'Don't replace inside variables + sValue = oParseTilde.Replace(sValue,"${HOME}") 'XDG Base Directory Specification has default values sValue = sValue.Replace("${XDG_DATA_HOME}", "${XDG_DATA_HOME:-~/.local/share}") sValue = sValue.Replace("${XDG_CONFIG_HOME}", "${XDG_CONFIG_HOME:-~/.config}")