Skip to content

Commit 9b76fab

Browse files
committed
Fixing setenv
1 parent 86168b1 commit 9b76fab

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ endif()
5959

6060
# Project version number
6161
set(PRJ_VERSION_MAJOR 1)
62-
set(PRJ_VERSION_MINOR 2)
62+
set(PRJ_VERSION_MINOR 2.1)
6363

6464
if (EXISTS "${PROJECT_SOURCE_DIR}/.git" AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
6565
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/cmake/githash.sh ${GIT_EXECUTABLE}

util/setenv.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func PrepareUserEnvironment(path string, debug bool) error {
5353
parts := strings.Split(val, ":")
5454
vals := make([]string, 0, len(parts))
5555
for _, part := range parts {
56-
if len(parts) == 0 {
56+
if len(part) == 0 {
5757
continue
5858
}
5959
if !strings.HasPrefix(part, varName) {
@@ -98,7 +98,7 @@ func CleanUserEnvironment(debug bool) error {
9898
parts := strings.Split(val, ":")
9999
vals := make([]string, 0, len(parts))
100100
for _, part := range parts {
101-
if len(parts) == 0 {
101+
if len(part) == 0 {
102102
continue
103103
}
104104
if !strings.HasPrefix(part, varName) {
@@ -107,10 +107,18 @@ func CleanUserEnvironment(debug bool) error {
107107
}
108108
val = strings.Join(vals, ":")
109109

110-
if err := k.SetStringValue(wslName, val); err != nil {
111-
return err
112-
} else if debug {
113-
log.Printf("Set '%s=%s'", wslName, val)
110+
if len(val) == 0 {
111+
if err := k.DeleteValue(wslName); err != nil {
112+
return err
113+
} else if debug {
114+
log.Printf("Del '%s'", wslName)
115+
}
116+
} else {
117+
if err := k.SetStringValue(wslName, val); err != nil {
118+
return err
119+
} else if debug {
120+
log.Printf("Set '%s=%s'", wslName, val)
121+
}
114122
}
115123

116124
notifySystem()

0 commit comments

Comments
 (0)