View Issue Details

IDProjectCategoryView StatusLast Update
0004067OpenFOAMBugpublic2024-03-27 19:55
Reporterblackk100 Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformGNU/Linux WSL2OSUbuntuOS Version22.04
Product Version11 
Summary0004067: Cleaned PATH eats up valid paths
DescriptionfoamCleanPath considers whitespaces and colons as valid field separators, although Linux only specifies colons for splitting the actual paths (at least according to this https://www.linfo.org/path_env_var.html).

This is especially an issue on WSL 2 as Windows appends its own PATH when installing the OS (in the form of /mnt/c/Program Files/...). This results in the user being unable to call Windows executables from the WSL OS (such as VS Code or explorer.exe).
Steps To ReproduceSource etc/bashrc
Additional InformationThis can be fixed easily if a copy of the PATH variable is made before souring etc/bashrc:

win_path=$(sed "s|^$(sed "s|:/mnt.*$||g" <<< $PATH)||g" <<< $PATH)
. /opt/openfoam11/etc/bashrc
export PATH=$(sed "s|:/mnt.*$|$win_path|g" <<< $PATH)
unset win_path
TagsNo tags attached.

Activities

blackk100

2024-03-27 19:55

reporter   ~0013219

This is an update to the workaround to deal with regex metacharacters in the PATH. This also assumes that the first mount point in the PATH is located after any OpenFOAM paths, and is run in bash.

path_wsl=$(sed 's|:/mnt.*||' <<< $PATH)
path_wsl=$(sed -e 's|\^|\\\^|g' -e 's|\$|\\\$|g' -e 's|\*|\\\*|g' -e 's|\+|\\\+|g' -e 's|\?|\\\?|g' -e 's|\.|\\\.|g' <<< $path_wsl)
path_win=$(sed "s|^$path_wsl||" <<< $PATH)
. /opt/openfoam11/etc/bashrc
path_wsl=$(sed 's|:/mnt.*||' <<< $PATH)
export PATH="$path_wsl$path_win"
unset path_wsl path_win

Issue History

Date Modified Username Field Change
2024-03-26 02:04 blackk100 New Issue
2024-03-27 19:55 blackk100 Note Added: 0013219